pub struct HostContext {Show 14 fields
pub project_root: PathBuf,
pub mesh_agent: Option<Arc<MeshAgent>>,
pub mcp_manager: Arc<RwLock<McpManager>>,
pub http_client: Client,
pub sql_conn: Arc<Mutex<Connection>>,
pub sql_interrupt: Arc<InterruptHandle>,
pub kv_conn: Arc<Mutex<Connection>>,
pub kv_interrupt: Arc<InterruptHandle>,
pub ts_conn: Arc<Mutex<Connection>>,
pub ts_interrupt: Arc<InterruptHandle>,
pub isle: Arc<AsyncIsle>,
pub handler_isle: Arc<AsyncIsle>,
pub bus_tx: Sender<Event>,
pub event_bus: Arc<Mutex<Option<EventBus>>>,
}Expand description
Shared context passed into Lua bridge functions.
Fields§
§project_root: PathBuf§mesh_agent: Option<Arc<MeshAgent>>§mcp_manager: Arc<RwLock<McpManager>>§http_client: ClientShared async HTTP client for http.* bridge.
sql_conn: Arc<Mutex<Connection>>Shared SQLite connection for sql.* bridge (user tables).
sql_interrupt: Arc<InterruptHandle>Interrupt handle for the sql connection.
Used to cancel in-flight queries on timeout (see bridge/sql.rs).
kv_conn: Arc<Mutex<Connection>>Shared SQLite connection for kv.* bridge (__kv table only).
Separate from sql_conn so KV scratch state and user SQL data don’t
share WAL, page cache, or backup lifecycle.
kv_interrupt: Arc<InterruptHandle>Interrupt handle for the kv connection.
ts_conn: Arc<Mutex<Connection>>Shared SQLite connection for ts.* bridge (TSDB — time-series table).
Separate DB file so TSDB WAL does not share page cache with kv/sql.
ts_interrupt: Arc<InterruptHandle>Interrupt handle for the ts connection.
Used by bridge::ts to cancel in-flight queries on timeout (Subtask 2).
isle: Arc<AsyncIsle>Async handle to the main Isle Lua VM that runs the user script via
coroutine_eval. After Subtask 2, bridge::bus no longer dispatches
handlers against this Isle; handlers live on handler_isle instead.
The field is retained because bridge code still keyed to the main
Isle (future coroutine_call back-edges, introspection APIs) may
need it, and removing it would force another HostContext reshape.
handler_isle: Arc<AsyncIsle>Dedicated Isle for EventBus handler execution. Lua handlers
registered via bus.on / bus.on_any run here so that CPU-bound
handler code does not occupy the main Isle’s LocalSet and block
grace timers / shutdown wakers on the main VM side.
Used by bridge::bus to forward handler bytecode
(Function::dump(true) → handler_isle.exec(...)) and by
LuaHandler::call to dispatch via
coroutine_call("__bus_dispatch", ...).
bus_tx: Sender<Event>Ingress sender for the EventBus. Adapters (mesh / webhook / …)
clone this and push Events. The ST3 mesh adapter captures its own
clone at MeshAgent::connect time, so the field itself is not read
elsewhere in the ST3 cut — kept pub for ST4+ adapter wiring.
event_bus: Arc<Mutex<Option<EventBus>>>Mutex-wrapped Option<EventBus> so bus.on / bus.on_any can lock
briefly from sync Lua context, and bus.serve can Option::take
ownership before entering the long-lived run() await (avoiding the
await-holding-lock anti-pattern on a std::sync::Mutex).
Trait Implementations§
Source§impl Clone for HostContext
impl Clone for HostContext
Source§fn clone(&self) -> HostContext
fn clone(&self) -> HostContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HostContext
impl !UnwindSafe for HostContext
impl Freeze for HostContext
impl Send for HostContext
impl Sync for HostContext
impl Unpin for HostContext
impl UnsafeUnpin for HostContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more