Skip to content

Instantly share code, notes, and snippets.

@ochaton
Created October 3, 2023 13:34
Show Gist options
  • Save ochaton/19835252b4ec51cb58a79778b99846ad to your computer and use it in GitHub Desktop.
Save ochaton/19835252b4ec51cb58a79778b99846ad to your computer and use it in GitHub Desktop.
require 'compat'.json_escape_forward_slash = 'new'
local log = require 'log'
local json = require 'json'
local netbox = require 'net.box'
local router = netbox.connect('127.0.0.1:4401')
log.info("call_raw: %s", json.encode(router:call('call_raw')))
log.info("call_noraw: %s", json.encode(router:call('call_noraw')))
--[[
call_raw: {"result":[{"status":"ok","message":"pong"},"storage"]}
call_noraw: {"result":{"status":"ok","message":"pong"}}
]]
box.cfg{listen=4401,memtx_dir='router',wal_dir='router',vinyl_dir='router'}
box.schema.user.grant('guest', 'super', nil, nil, { if_not_exists = true })
local netbox = require 'net.box'
local storage = netbox.connect('127.0.0.1:3301')
function call_raw()
local res = storage:call('storage_ping', {}, { return_raw=true })
return {
result = res
}
end
function call_noraw()
local res = storage:call('storage_ping', {})
return {
result = res,
}
end
box.cfg{listen=3301,memtx_dir='storage',wal_dir='storage',vinyl_dir='storage'}
box.schema.user.grant('guest', 'super', nil, nil, { if_not_exists = true })
function storage_ping()
return { status = 'ok', message = 'pong' }, 'storage'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment