add cluster.register and cluster.query

This commit is contained in:
Cloud Wu
2015-08-14 23:22:00 +08:00
parent a38a3140dd
commit 2583af26d7
5 changed files with 54 additions and 13 deletions

View File

@@ -2,15 +2,18 @@ local skynet = require "skynet"
local cluster = require "cluster"
skynet.start(function()
local proxy = cluster.proxy("db", ".simpledb")
-- query name "sdb" of cluster db.
local sdb = cluster.query("db", "sdb")
print("db.sbd=",sdb)
local proxy = cluster.proxy("db", sdb)
local largekey = string.rep("X", 128*1024)
local largevalue = string.rep("R", 100 * 1024)
print(skynet.call(proxy, "lua", "SET", largekey, largevalue))
local v = skynet.call(proxy, "lua", "GET", largekey)
assert(largevalue == v)
print(cluster.call("db", ".simpledb", "GET", "a"))
print(cluster.call("db2", ".simpledb", "GET", "b"))
print(cluster.call("db", sdb, "GET", "a"))
print(cluster.call("db2", sdb, "GET", "b"))
-- test snax service
local pingserver = cluster.snax("db", "pingserver")