Skip to main content

SessionManager

Struct SessionManager 

Source
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

Source

pub fn new( max_concurrency: usize, event_tx: RuntimeEventSender, call_id_router: CallIdRouter, snapshot_cache: Arc<SnapshotCache>, ) -> Self

Source

pub fn snapshot_cache(&self) -> &Arc<SnapshotCache>

Get the snapshot cache for pre-warming from WarmSnapshot messages.

Source

pub fn pre_warm_workers( &self, bridge_code: String, userland_code: String, heap_limit_mb: Option<u32>, count: usize, )

Source

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.

Source

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>

Source

pub fn destroy_session_if_output_generation( &mut self, session_id: &str, output_generation: u64, ) -> Result<bool, String>

Source

pub fn begin_destroy_session_if_output_generation( &mut self, session_id: &str, output_generation: u64, ) -> Result<Option<SessionShutdown>, String>

Source

pub fn detach_session_if_output_generation( &mut self, session_id: &str, output_generation: u64, ) -> Result<bool, String>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn session_count(&self) -> usize

Number of registered sessions (including those waiting for a slot).

Source

pub fn all_sessions(&self) -> Vec<String>

Return all session IDs.

Source

pub fn active_slot_count(&self) -> usize

Number of sessions that have acquired a concurrency slot.

Source

pub fn call_id_router(&self) -> &CallIdRouter

Get the call_id routing table for BridgeResponse dispatch.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more