Skip to main content

Pool

Struct Pool 

Source
pub struct Pool { /* private fields */ }
Expand description

An elastic pool of monty subprocess workers.

min_processes workers spawn eagerly so the first checkout is fast; further workers spawn on demand up to max_processes, and dead workers are detected and replaced transparently. See the crate docs for the full lifecycle.

Pool is safe to share across tasks and threads. Pool::close asks idle workers to exit cleanly; merely dropping the pool kills them instead (via their kill-on-drop handles). Workers held by live Checkouts die when those are finished or dropped.

Implementations§

Source§

impl Pool

Source

pub async fn new(config: PoolConfig) -> Result<Self, PoolError>

Creates the pool and eagerly spawns min_processes workers, failing fast if the binary cannot be spawned. Must be called within a tokio runtime (worker process and pipe I/O is driven by the runtime).

Source

pub async fn checkout(&self, repl: &ReplConfig) -> Result<Checkout, PoolError>

Dedicates a worker to one REPL session created from repl, with default CheckoutOptions — see Self::checkout_with.

Source

pub async fn checkout_with( &self, repl: &ReplConfig, options: CheckoutOptions, ) -> Result<Checkout, PoolError>

Dedicates a worker to one REPL session created from repl, with the host context options carries.

Takes an idle worker when one exists, spawns or dials a new one (with options.connect_headers, preceded by the W3C trace headers of options.telemetry) while below max_processes, and otherwise waits up to checkout_timeout (forever when None) before failing with PoolError::Exhausted.

Source

pub async fn close(&self)

Asks idle workers to exit cleanly and reaps them, capping the wait per worker. Sessions still checked out keep their workers until they finish.

Optional: dropping the pool kills idle workers instead, which is just as safe — this only trades a SIGKILL for a clean protocol goodbye.

Telemetry exporter shutdown remains the configuring application’s responsibility and should happen after checked-out sessions finish.

Source

pub fn idle_workers(&self) -> usize

Number of idle workers right now (diagnostics/tests only — the value is stale the moment it is returned).

Source

pub fn idle_worker_pids(&self) -> Vec<u32>

PIDs of the idle workers (diagnostics/tests only).

Auto Trait Implementations§

§

impl Freeze for Pool

§

impl RefUnwindSafe for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl UnsafeUnpin for Pool

§

impl UnwindSafe for Pool

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V