It tarantool-cartridge
.
Caller function:
local function http_redirections(req)
log.info("-- redirections started")
local b_id = tostring(req)
local bucket_id = vshard.router.bucket_id_mpcrc32(b_id)
log.info("-- bucket_id: %s", bucket_id)
local answer, error = err_vshard_router:pcall(
vshard.router.call,
bucket_id,
'read',
'redirections'
)
for k, v in pairs(answer) do log.info(" http: key: %s value: %s", k, v) end
end
Handler:
local function redirections(req)
log.info("-- redirections handler started")
local response = {}
local answer = {}
response = box.space.space_name:select()
for k, v in pairs(response) do answer[k] = v end
for k, v in pairs(answer) do log.info("key: %s value: %s", k, v) end
log.info("-- response size: %d", #answer)
return answer
end
Result in the calling function: http: key: 1 value: table: 0x418e3d10 http: key: 2 value
Result in handler OK: key = value from select(). Why does a table from a table return to the calling function ?
In short, you don't have any legal ways to return tuples from netbox/vshard call.
How does it work:
But if you use connection you could directly call "select/insert/..." functions directly. Since Tarantool 2.2 such tuples even have a format. For details see issue.
If you need to convert lua tables to tuples you could use box.tuple.new() function. But it will be tuples without format.
And here I should finish my answer. But you have illegal way to return formatted tuples from netbox call.
This code works since Tarantool 2.2 and easily could be broken in future as it uses some internal Tarantool functions. I don't recommend you to use them. I hope it will be changed after this issue will be resolved.