pub struct SessionManager { /* private fields */ }Expand description
Manages V8 sessions with concurrency limiting. Each session runs on a dedicated OS thread with its own V8 isolate.
Implementations§
Source§impl SessionManager
impl SessionManager
pub fn new( max_concurrency: usize, event_tx: RuntimeEventSender, call_id_router: CallIdRouter, snapshot_cache: Arc<SnapshotCache>, ) -> Self
Sourcepub fn snapshot_cache(&self) -> &Arc<SnapshotCache> ⓘ
pub fn snapshot_cache(&self) -> &Arc<SnapshotCache> ⓘ
Get the snapshot cache for pre-warming from WarmSnapshot messages.
pub fn pre_warm_workers( &self, bridge_code: String, userland_code: String, heap_limit_mb: Option<u32>, count: usize, )
Sourcepub fn create_session(
&mut self,
session_id: String,
heap_limit_mb: Option<u32>,
cpu_time_limit_ms: Option<u32>,
wall_clock_limit_ms: Option<u32>,
) -> Result<(), String>
pub fn create_session( &mut self, session_id: String, heap_limit_mb: Option<u32>, cpu_time_limit_ms: Option<u32>, wall_clock_limit_ms: Option<u32>, ) -> Result<(), String>
Create a new session. Spawns a dedicated thread with a V8 isolate. If max concurrency is reached, the session thread will block until a slot becomes available.
pub fn create_session_with_output_generation( &mut self, session_id: String, heap_limit_mb: Option<u32>, cpu_time_limit_ms: Option<u32>, wall_clock_limit_ms: Option<u32>, output_generation: Option<u64>, warm_hint: Option<WarmSessionHint>, ) -> Result<(), String>
pub fn destroy_session_if_output_generation( &mut self, session_id: &str, output_generation: u64, ) -> Result<bool, String>
pub fn begin_destroy_session_if_output_generation( &mut self, session_id: &str, output_generation: u64, ) -> Result<Option<SessionShutdown>, String>
pub fn detach_session_if_output_generation( &mut self, session_id: &str, output_generation: u64, ) -> Result<bool, String>
Sourcepub fn destroy_session(&mut self, session_id: &str) -> Result<(), String>
pub fn destroy_session(&mut self, session_id: &str) -> Result<(), String>
Destroy a session inline. Joins the session thread before returning, so
this must not be called while a shared lock on the manager is held. Lock
holders use begin_destroy_session and call finish() after unlocking.
Sourcepub fn begin_destroy_session(
&mut self,
session_id: &str,
) -> Result<SessionShutdown, String>
pub fn begin_destroy_session( &mut self, session_id: &str, ) -> Result<SessionShutdown, String>
First phase of destroying a session: terminate execution, signal abort, send shutdown, clear call routes, and remove the entry. The returned shutdown joins the session thread and must be finished after the SessionManager lock is released.
Sourcepub fn session_command_sender(
&self,
session_id: &str,
msg: &SessionMessage,
) -> Result<Sender<SessionCommand>, String>
pub fn session_command_sender( &self, session_id: &str, msg: &SessionMessage, ) -> Result<Sender<SessionCommand>, String>
Resolve a session’s command sender and apply message side effects that must happen under the manager lock (isolate termination, abort signal). The caller sends on the returned channel after releasing the lock so a full command channel cannot block the manager mutex.
Sourcepub fn session_sender(
&self,
session_id: &str,
) -> Result<Sender<SessionCommand>, String>
pub fn session_sender( &self, session_id: &str, ) -> Result<Sender<SessionCommand>, String>
Get a session’s command sender without a message (used for control commands like SetModuleReader that aren’t a SessionMessage). Dispatch-thread only.
Sourcepub fn send_to_session(
&self,
session_id: &str,
msg: SessionMessage,
) -> Result<(), String>
pub fn send_to_session( &self, session_id: &str, msg: SessionMessage, ) -> Result<(), String>
Send a message to a session. Blocks on the session command channel, so this must not be called while a shared lock on the manager is held.
Sourcepub fn destroy_sessions<I>(&mut self, session_ids: I)where
I: IntoIterator<Item = String>,
pub fn destroy_sessions<I>(&mut self, session_ids: I)where
I: IntoIterator<Item = String>,
Destroy a set of sessions inline, ignoring sessions that were already removed. Joins session threads, so this must not be called while a shared lock on the manager is held.
Sourcepub fn begin_destroy_sessions<I>(
&mut self,
session_ids: I,
) -> Vec<SessionShutdown>where
I: IntoIterator<Item = String>,
pub fn begin_destroy_sessions<I>(
&mut self,
session_ids: I,
) -> Vec<SessionShutdown>where
I: IntoIterator<Item = String>,
Begin destroying a set of sessions, ignoring sessions that were already removed. Finish each returned shutdown after releasing the manager lock.
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Number of registered sessions (including those waiting for a slot).
Sourcepub fn all_sessions(&self) -> Vec<String>
pub fn all_sessions(&self) -> Vec<String>
Return all session IDs.
Sourcepub fn active_slot_count(&self) -> usize
pub fn active_slot_count(&self) -> usize
Number of sessions that have acquired a concurrency slot.
Sourcepub fn call_id_router(&self) -> &CallIdRouter
pub fn call_id_router(&self) -> &CallIdRouter
Get the call_id routing table for BridgeResponse dispatch.