forked from thibaultcha/lua-cassandra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentication.lua
More file actions
39 lines (31 loc) · 887 Bytes
/
Copy pathauthentication.lua
File metadata and controls
39 lines (31 loc) · 887 Bytes
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
--------------------------------
-- Single host module, plain Lua
--------------------------------
local cassandra = require "cassandra"
local peer = assert(cassandra.new {
auth = cassandra.auth_providers.plain_text("cassandra", "cassandra")
})
assert(peer:connect())
----------------------------
-- Cluster module, OpenResty
----------------------------
http {
# shm storing cluster information
lua_shared_dict cassandra 1m;
server {
...
location / {
content_by_lua_block {
local cassandra = require "cassandra"
local Cluster = require "resty.cassandra.cluster"
local cluster, err = Cluster.new {
auth = cassandra.auth_providers.plain_text("cassandra", "cassandra")
}
if not cluster then
ngx.log(ngx.ERR, "could not create cluster: ", err)
ngx.exit(500)
end
}
}
}
}