local Cluster = require "resty.cassandra.cluster"
local dc_rr = require "resty.cassandra.policies.lb.dc_rr"
local cluster
local _M = {}
function _M.init()
local policy = dc_rr.new("local_dc")
cluster = Cluster.new({
shm = 'cassandra', -- defined by the lua_shared_dict directive
contact_points = { '10.10.10.10' },
keyspace = 'my_keyspace',
lb_policy = policy
})
assert(cluster.refresh())
end
function _M.execute(...)
return cluster:execute(...)
end
return _M`
In the HTTP context,
init_by_lua_file lua/init.lua;
init.lua
local cc = require 'my_module'
cc.init()
Then execute sbin/nginx -t shows the error:
nginx: [error] init_by_lua_file error: resty/cassandra/cluster.lua:117: attempt to index local 'self' (a nil value)
stack traceback:
resty/cassandra/cluster.lua:117: in function 'get_peers'
resty/cassandra/cluster.lua:448: in function 'refresh'
my_module.lua
In the HTTP context,
init_by_lua_file lua/init.lua;
init.lua
Then execute
sbin/nginx -t
shows the error:And the nginx version is
Luajit version is
luajit-2.1.0-beta2