-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.lua
More file actions
53 lines (42 loc) · 1.1 KB
/
example.lua
File metadata and controls
53 lines (42 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- package.path = package.path .. ';../libs/share/lua/5.1/?/init.lua;../libs/share/lua/5.1/?.lua;'
box.cfg {
background = false;
logger_nonblock = true;
read_only = true;
wal_mode = 'none';
}
local ffi = require 'ffi'
local fiber = require 'fiber'
local function dump(x)
local j = require'json'.new()
j.cfg{
encode_use_tostring = true;
}
return j.encode(x)
end
-- print(ffi.C.TNT_UPDATE_INSERT)
local scr = require 'connection.scribe'
local cn = scr("localhost",1463,{})
fiber.create(function()
-- print("preparing to connect", cn)
local ch = fiber.channel(1)
cn.on_connected = function(self,...)
-- print("connected", ...)
-- print(cn)
ch:put(false)
end
cn.on_connfail = function(self,...)
print("connfail", ...)
end
cn.on_disconnect = function(self,...)
print("disconnected", ...)
end
cn:connect()
-- print(cn)
ch:get()
-- print("go on,", cn)
print("log1 = ", cn:send{ cat = "test cat"; msg = "my test message" } )
print("log2 = ", cn:send{{ cat = "test cat"; msg = "my test message" }} )
print("log3 = ", cn:send("test cat","my test message") )
print("log4 = ", cn:send({}) )
end)