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: impl Into<RuntimeEventSender>, call_id_router: CallIdRouter, snapshot_cache: Arc<SnapshotCache>, runtime: RuntimeContext, ) -> 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 admitted thread with a V8 isolate. Admission happens before thread creation; overload returns a typed limit error.

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 create_session_with_output_generation_and_sender( &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>, event_tx: Option<RuntimeEventSender>, ) -> Result<(), String>

Source

pub fn create_session_with_output_generation_sender_and_runtime( &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>, event_tx: Option<RuntimeEventSender>, session_runtime: RuntimeContext, ready_batch_handle_limit: usize, bridge_call_timeout: Duration, ) -> Result<(), String>

Create a session whose guest-owned work and resource reservations are charged to session_runtime. The manager’s own runtime remains the process-scoped context used for shared snapshot and warm-pool work.

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>, usize), 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 try_send_to_session( &self, session_id: &str, msg: SessionMessage, ) -> Result<(), String>

Admit an ordinary message without ever blocking the thread that also routes call-specific bridge responses. Readiness must use publish_readiness; ordinary events are never reclassified by name.

Source

pub fn publish_readiness( &self, session_id: &str, capability_id: u64, capability_generation: u64, flags: ReadyFlags, ) -> Result<(), String>

Source

pub fn publish_signal( &self, session_id: &str, signal: i32, ) -> Result<(), String>

Source

pub fn remove_readiness( &self, session_id: &str, capability_id: u64, capability_generation: u64, ) -> Result<(), String>

Source

pub fn set_application_read_interest( &self, session_id: &str, capability_id: u64, capability_generation: u64, enabled: bool, ) -> Result<(), String>

Source

pub fn publish_timer( &self, session_id: &str, timer_id: u64, ) -> Result<(), String>

Source

pub fn session_sender( &self, session_id: &str, ) -> Result<(Sender<SessionCommand>, usize), 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 pause_session(&self, session_id: &str) -> Result<(), String>

Pause a session at the V8 execution boundary. A running synchronous script is interrupted on its isolate thread and remains parked with its JavaScript stack intact until resume_session is called.

Source

pub fn resume_session(&self, session_id: &str) -> Result<(), String>

Source

pub fn send_to_session( &self, session_id: &str, msg: SessionMessage, ) -> Result<(), String>

Send a message to a session without blocking response/control progress.

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 quarantined_session_count(&mut self) -> usize

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 session_output_generation(&self, session_id: &str) -> Option<u64>

Source

pub fn call_id_router(&self) -> &CallIdRouter

Get the direct bridge-call response registry.

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