fix: lib name is codemp_lua, override addr via env

use CODEMP_SERVER_ADDRESS
This commit is contained in:
əlemi 2024-08-06 23:01:44 +02:00
parent 05a4c88967
commit cd9a2d6247
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -19,8 +19,9 @@ struct GlobalState {
impl Default for GlobalState { impl Default for GlobalState {
fn default() -> Self { fn default() -> Self {
let rt = Runtime::new().expect("could not create tokio runtime"); let rt = Runtime::new().expect("could not create tokio runtime");
let addr = std::env::var("CODEMP_SERVER_ADDRESS").unwrap_or_else(|_|"http://codemp.alemi.dev:50053".to_string());
let client = rt.block_on( let client = rt.block_on(
CodempClient::new("http://codemp.alemi.dev:50053") CodempClient::new(&addr)
).expect("could not connect to codemp servers"); ).expect("could not connect to codemp servers");
GlobalState { client: std::sync::RwLock::new(client), runtime: rt } GlobalState { client: std::sync::RwLock::new(client), runtime: rt }
} }
@ -248,7 +249,7 @@ fn setup_tracing(_: &Lua, (debug,): (Option<bool>,)) -> LuaResult<LuaLogger> {
// define module and exports // define module and exports
#[mlua::lua_module] #[mlua::lua_module]
fn libcodemp(lua: &Lua) -> LuaResult<LuaTable> { fn codemp_lua(lua: &Lua) -> LuaResult<LuaTable> {
let exports = lua.create_table()?; let exports = lua.create_table()?;
// core proto functions // core proto functions