support @name, see #823

This commit is contained in:
Cloud Wu
2018-04-19 14:54:25 +08:00
committed by 云风
parent f4d5bc7aa4
commit 182d7c7dc7
4 changed files with 47 additions and 17 deletions

View File

@@ -2,10 +2,7 @@ local skynet = require "skynet"
local cluster = require "skynet.cluster"
skynet.start(function()
-- query name "sdb" of cluster db.
local sdb = cluster.query("db", "sdb")
print("db.sbd=",sdb)
local proxy = cluster.proxy("db", sdb)
local proxy = cluster.proxy "db@sdb" -- cluster.proxy("db", "@sdb")
local largekey = string.rep("X", 128*1024)
local largevalue = string.rep("R", 100 * 1024)
skynet.call(proxy, "lua", "SET", largekey, largevalue)
@@ -13,9 +10,9 @@ skynet.start(function()
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)
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
skynet.timeout(300,function()
@@ -23,7 +20,7 @@ skynet.start(function()
db = false, -- db is down
db3 = "127.0.0.1:2529"
}
print(pcall(cluster.call, "db", sdb, "GET", "a")) -- db is down
print(pcall(cluster.call, "db", "@sdb", "GET", "a")) -- db is down
end)
local pingserver = cluster.snax("db3", "pingserver")
print(pingserver.req.ping "hello")