I want to create connection to Tarantool database in init_by_lua_block
or init_worker_by_lua_block
and then use that created connection in each content_by_lua_block
:
init_by_lua_block {
local tnt = require 'resty.tarantool'
local tar, err = tnt:new({
host = '127.0.0.1',
port = 3312,
user = 'user',
password = 'password',
socket_timeout = 2000
})
local res, err = tar:connect()
}
But cosocket api is disabled in directives init_*_by_lua*
. How I can create connection one time instead of creating connections for each request?