Struct LuaHost
pub struct LuaHost<T: 'static> { /* private fields */ }Expand description
kevy-side per-shard Lua host. Wraps a kevy_lua::Bridge plus
the scoped-pointer plumbing.
T is whatever shard state the dispatch closure needs (Store,
KeyspaceStore, …). It must outlive every LuaHost::eval call
(trivially true: kevy holds the &mut T while delegating).
Implementations§
§impl<T: 'static> LuaHost<T>
impl<T: 'static> LuaHost<T>
pub fn new<F>(dispatch_fn: F) -> Self
pub fn new<F>(dispatch_fn: F) -> Self
Build a host with dispatch_fn as the redis.call backend.
dispatch_fn receives a &mut T (the current shard context),
the script’s argv (command + args), and the read_only flag.
It must return RESP reply bytes — production callers route to
kevy’s dispatch, tests just return canned replies.
The closure receives &mut T via with_current, so it
must be Fn(&mut T, …) -> … rather than FnMut. (kevy’s
dispatch path is &mut self, so Fn(&mut T, …) is exactly
what we need.)
pub fn eval(
&mut self,
ctx: &mut T,
script: &[u8],
keys: &[&[u8]],
args: &[&[u8]],
) -> Reply
pub fn eval( &mut self, ctx: &mut T, script: &[u8], keys: &[&[u8]], args: &[&[u8]], ) -> Reply
Run a script. Scoped-installs ctx so the dispatch closure
can find it via with_current, then delegates to
Bridge::eval.
pub fn eval_ro(
&mut self,
ctx: &mut T,
script: &[u8],
keys: &[&[u8]],
args: &[&[u8]],
) -> Reply
pub fn eval_ro( &mut self, ctx: &mut T, script: &[u8], keys: &[&[u8]], args: &[&[u8]], ) -> Reply
Read-only counterpart of Self::eval.
pub fn evalsha(
&mut self,
ctx: &mut T,
sha1: ScriptSha1,
keys: &[&[u8]],
args: &[&[u8]],
) -> Reply
pub fn evalsha( &mut self, ctx: &mut T, sha1: ScriptSha1, keys: &[&[u8]], args: &[&[u8]], ) -> Reply
Run a previously-loaded script by SHA1.
pub fn evalsha_ro(
&mut self,
ctx: &mut T,
sha1: ScriptSha1,
keys: &[&[u8]],
args: &[&[u8]],
) -> Reply
pub fn evalsha_ro( &mut self, ctx: &mut T, sha1: ScriptSha1, keys: &[&[u8]], args: &[&[u8]], ) -> Reply
Read-only EVALSHA.
pub fn script_load(&mut self, script: &[u8]) -> ScriptSha1
pub fn script_load(&mut self, script: &[u8]) -> ScriptSha1
SCRIPT LOAD — cache without running. No context needed.
pub fn script_exists(&self, sha1s: &[ScriptSha1]) -> Vec<bool>
pub fn script_exists(&self, sha1s: &[ScriptSha1]) -> Vec<bool>
SCRIPT EXISTS.
pub fn script_flush(&mut self, mode: FlushMode)
pub fn script_flush(&mut self, mode: FlushMode)
SCRIPT FLUSH.
pub fn set_instr_budget(&mut self, n: i64)
pub fn set_instr_budget(&mut self, n: i64)
Forward kevy_lua::Bridge::set_instr_budget — set the
per-Vm instruction cap. The operator wires [lua] time_limit_ms here at server startup.