add cluster.proxy and cluster.ncall

This commit is contained in:
Cloud Wu
2014-08-13 17:49:30 +08:00
parent cde423cb73
commit 978e010e67
11 changed files with 79 additions and 9 deletions

View File

@@ -93,6 +93,7 @@ local function monitor_master(master_fd)
local fd = slaves[id_name]
slaves[id_name] = false
if fd then
monitor_clear(id_name)
socket.close(fd)
end
end
@@ -143,14 +144,14 @@ local function monitor_harbor(master_fd)
return function(session, source, command)
local t = string.sub(command, 1, 1)
local arg = string.sub(command, 3)
if t == "Q" then
if t == 'Q' then
-- query name
if globalname[arg] then
skynet.redirect(harbor_service, globalname[arg], "harbor", 0, "N " .. arg)
else
socket.write(master_fd, pack_package("Q", arg))
end
elseif t == "D" then
elseif t == 'D' then
-- harbor down
local id = tonumber(arg)
if slaves[id] then
@@ -194,6 +195,10 @@ function harbor.CONNECT(fd, id)
end
function harbor.QUERYNAME(fd, name)
if name:byte() == 46 then -- "." , local name
skynet.ret(skynet.pack(skynet.localname(name)))
return
end
local result = globalname[name]
if result then
skynet.ret(skynet.pack(result))