complete cluster.send

This commit is contained in:
Cloud Wu
2017-03-25 00:10:23 +08:00
parent 3a4a673b43
commit 6289b2b8e4
7 changed files with 90 additions and 23 deletions

View File

@@ -11,9 +11,11 @@ skynet.start(function()
print(skynet.call(proxy, "lua", "SET", largekey, largevalue))
local v = skynet.call(proxy, "lua", "GET", largekey)
assert(largevalue == v)
skynet.send(proxy, "lua", "PING", "proxy")
print(cluster.call("db", sdb, "GET", "a"))
print(cluster.call("db2", sdb, "GET", "b"))
cluster.send("db2", sdb, "PING", "db2:longstring" .. largevalue)
-- test snax service
local pingserver = cluster.snax("db", "pingserver")

View File

@@ -16,7 +16,17 @@ end
skynet.start(function()
skynet.dispatch("lua", function(session, address, cmd, ...)
local f = command[string.upper(cmd)]
cmd = cmd:upper()
if cmd == "PING" then
assert(session == 0)
local str = (...)
if #str > 20 then
str = str:sub(1,20) .. "...(" .. #str .. ")"
end
skynet.error(string.format("%s ping %s", skynet.address(address), str))
return
end
local f = command[cmd]
if f then
skynet.ret(skynet.pack(f(...)))
else