Skip to content
Snippets Groups Projects
Commit 332dc8c7 authored by Igor Kuznetsov's avatar Igor Kuznetsov
Browse files

refactor: extract `fiber_id` function to the lua path

parent 646ec5c8
No related branches found
No related tags found
1 merge request!1414sbroad import
local cartridge = require('cartridge')
_G.fiber_id = function ()
local fiber = require('fiber')
return fiber.id()
end
_G.get_jaeger_agent_host = function()
local cfg = cartridge.config_get_readonly()
if cfg["jaeger_agent_host"] == nil then
return "localhost"
end
return cfg["jaeger_agent_host"]
end
_G.get_jaeger_agent_port = function()
local cfg = cartridge.config_get_readonly()
if cfg["jaeger_agent_port"] == nil then
return 6831
end
return cfg["jaeger_agent_port"]
end
#[cfg(not(feature = "mock"))]
pub(super) fn fiber_id() -> u64 {
static mut FIBER_FUNC_DEFINED: bool = false;
let lua = global_lua();
let lua = tarantool::lua_state();
if !unsafe { FIBER_FUNC_DEFINED } {
#[rustfmt::skip]
lua.exec(
r#"
function fiber_id()
local fiber = require('fiber')
return fiber.id()
end
"#,
).unwrap();
unsafe {
FIBER_FUNC_DEFINED = true;
}
}
lua.get::<tarantool::tlua::LuaFunction<_>, _>("fiber_id")
.unwrap()
.into_call()
.unwrap()
}
#[cfg(not(feature = "mock"))]
fn global_lua() -> tarantool::tlua::StaticLua {
use tarantool::tlua::Lua;
unsafe { Lua::from_static(tarantool::ffi::tarantool::luaT_state()) }
}
require('strict').on()
require('sbroad')
local vshard = require('vshard')
local cartridge = require('cartridge')
......@@ -8,26 +9,6 @@ _G.get_schema = function()
return cartridge.get_schema()
end
_G.get_jaeger_agent_host = function()
local cfg = cartridge.config_get_readonly()
if cfg["jaeger_agent_host"] == nil then
return "localhost"
end
return cfg["jaeger_agent_host"]
end
_G.get_jaeger_agent_port = function()
local cfg = cartridge.config_get_readonly()
if cfg["jaeger_agent_port"] == nil then
return 6831
end
return cfg["jaeger_agent_port"]
end
_G.get_waiting_timeout = function()
local cfg = cartridge.config_get_readonly()
......
require('strict').on()
require('sbroad')
local cartridge = require('cartridge')
_G.get_storage_cache_capacity = function()
......@@ -22,26 +24,6 @@ _G.get_storage_cache_size_bytes = function()
return cfg["storage_cache_size_bytes"]
end
_G.get_jaeger_agent_host = function()
local cfg = cartridge.config_get_readonly()
if cfg["jaeger_agent_host"] == nil then
return "localhost"
end
return cfg["jaeger_agent_host"]
end
_G.get_jaeger_agent_port = function()
local cfg = cartridge.config_get_readonly()
if cfg["jaeger_agent_port"] == nil then
return 6831
end
return cfg["jaeger_agent_port"]
end
_G.prepare = function(pattern)
local prep, err = box.prepare(pattern)
if err ~= nil then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment