Skip to main content

LuaHost

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>

pub fn new<F>(dispatch_fn: F) -> Self
where F: Fn(&mut T, &[&[u8]], bool) -> Vec<u8> + 'static,

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

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

Read-only counterpart of Self::eval.

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

Read-only EVALSHA.

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>

SCRIPT EXISTS.

pub fn script_flush(&mut self, mode: FlushMode)

SCRIPT FLUSH.

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.

pub fn set_allowed_dialects(&mut self, versions: &[LuaVersion])

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for LuaHost<T>

§

impl<T> !Send for LuaHost<T>

§

impl<T> !Sync for LuaHost<T>

§

impl<T> !UnwindSafe for LuaHost<T>

§

impl<T> Freeze for LuaHost<T>
where PhantomData<fn() -> T>: Freeze,

§

impl<T> Unpin for LuaHost<T>
where PhantomData<fn() -> T>: Unpin,

§

impl<T> UnsafeUnpin for LuaHost<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.