mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
add module skynet.harbor
This commit is contained in:
11
test/testharborlink.lua
Normal file
11
test/testharborlink.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
local skynet = require "skynet"
|
||||
local harbor = require "skynet.harbor"
|
||||
|
||||
skynet.start(function()
|
||||
print("wait for harbor 2")
|
||||
print("run skynet examples/config_log please")
|
||||
harbor.connect(2)
|
||||
print("harbor 2 connected")
|
||||
harbor.link(2)
|
||||
print("disconnected")
|
||||
end)
|
||||
53
test/testredis2.lua
Normal file
53
test/testredis2.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local skynet = require "skynet"
|
||||
local redis = require "redis"
|
||||
|
||||
local db
|
||||
|
||||
function add1(key, count)
|
||||
local t = {}
|
||||
for i = 1, count do
|
||||
t[2*i -1] = "key" ..i
|
||||
t[2*i] = "value" .. i
|
||||
end
|
||||
db:hmset(key, table.unpack(t))
|
||||
end
|
||||
|
||||
function add2(key, count)
|
||||
local t = {}
|
||||
for i = 1, count do
|
||||
t[2*i -1] = "key" ..i
|
||||
t[2*i] = "value" .. i
|
||||
end
|
||||
table.insert(t, 1, key)
|
||||
db:hmset(t)
|
||||
end
|
||||
|
||||
function __init__()
|
||||
db = redis.connect {
|
||||
host = "127.0.0.1",
|
||||
port = 6300,
|
||||
db = 0,
|
||||
auth = "foobared"
|
||||
}
|
||||
print("dbsize:", db:dbsize())
|
||||
local ok, msg = xpcall(add1, debug.traceback, "test1", 250000)
|
||||
if not ok then
|
||||
print("add1 failed", msg)
|
||||
else
|
||||
print("add1 succeed")
|
||||
|
||||
end
|
||||
|
||||
local ok, msg = xpcall(add2, debug.traceback, "test2", 250000)
|
||||
if not ok then
|
||||
print("add2 failed", msg)
|
||||
else
|
||||
print("add2 succeed")
|
||||
end
|
||||
print("dbsize:", db:dbsize())
|
||||
|
||||
print("redistest launched")
|
||||
end
|
||||
|
||||
skynet.start(__init__)
|
||||
|
||||
Reference in New Issue
Block a user