mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
cluster servicename is not stable, so don't cache address
This commit is contained in:
@@ -8,7 +8,7 @@ Dev version
|
||||
* snax service add change SERVICE_PATH and add it to package.path
|
||||
* skynet.redirect support string address
|
||||
* add skynet.harbor.queryname to query globalname
|
||||
* add cluster.proxy and cluster.ncall
|
||||
* add cluster.proxy
|
||||
|
||||
v0.5.2 (2014-8-11)
|
||||
-----------
|
||||
|
||||
@@ -4,6 +4,5 @@ local cluster = require "cluster"
|
||||
skynet.start(function()
|
||||
local proxy = cluster.proxy("db", ".simpledb")
|
||||
print(skynet.call(proxy, "lua", "GET", "a"))
|
||||
print(cluster.ncall("db.simpledb","GET", "a"))
|
||||
print(cluster.call("db", ".simpledb", "GET", "a"))
|
||||
end)
|
||||
|
||||
@@ -24,19 +24,6 @@ function cluster.proxy(node, name)
|
||||
return skynet.call(clusterd, "lua", "proxy", node, name)
|
||||
end
|
||||
|
||||
local namecache = {}
|
||||
|
||||
function cluster.ncall(name, ...)
|
||||
local s = namecache[name]
|
||||
if not s then
|
||||
local node , lname = name:match "(.-)(%..+)"
|
||||
assert(node and lname)
|
||||
s = cluster.proxy(node, lname)
|
||||
namecache[name] = assert(s)
|
||||
end
|
||||
return skynet.call(s, "lua", ...)
|
||||
end
|
||||
|
||||
skynet.init(function()
|
||||
clusterd = skynet.uniqueservice("clusterd")
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user