-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
nginx.conf
58 lines (51 loc) · 1.66 KB
/
nginx.conf
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
54
55
56
57
58
daemon off;
error_log /dev/stderr info;
worker_processes auto;
env LD_LIBRARY_PATH;
env PYTHONPATH;
events {}
http {
server {
listen 20000;
location /gc {
content_by_lua_block {
collectgarbage()
ngx.say("ok")
}
}
location /echo {
content_by_lua_block {
require("resty_ffi")
local demo = ngx.load_ffi("resty_ffi_python", "ffi.echo?,init",
{is_global = true, unpin = true})
local ok, res = demo:echo("hello")
assert(ok)
assert(res == "hello")
demo:__unload()
ok, res = demo:echo("foobar")
assert(not ok)
ngx.log(ngx.ERR, res)
ngx.say("ok")
}
}
location /kafka {
content_by_lua_block {
require("resty_ffi")
local opts = {is_global = true}
local demo = ngx.load_ffi("resty_ffi_python",
[[ffi.kafka,init,{"servers":"localhost:9092", "topic":"foobar", "group_id": "foobar"}]], opts)
local ok, res
ok, res = demo:produce([[{"type":"produce", "msg":"hello"}]])
assert(ok)
ok, res = demo:produce([[{"type":"produce", "msg":"world"}]])
assert(ok)
local ok, res = demo:consume([[{"type":"consume"}]])
assert(ok)
ngx.say(res)
local ok, res = demo:consume([[{"type":"consume"}]])
assert(ok)
ngx.say(res)
}
}
}
}