cluster servicename is not stable, so don't cache address

This commit is contained in:
Cloud Wu
2014-08-13 19:10:51 +08:00
parent 2cf69a6ef0
commit 845acd3314
3 changed files with 1 additions and 15 deletions

View File

@@ -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)
-----------

View File

@@ -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)

View File

@@ -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)