Skip to main content

LeanWorkerSessionLease

Struct LeanWorkerSessionLease 

Source
pub struct LeanWorkerSessionLease<'pool> { /* private fields */ }
Expand description

Borrowed lease for running typed commands on a compatible worker session.

The lease does not expose which worker was selected. If a command triggers timeout, cancellation, child failure, or explicit cycle, the lease becomes invalid and a fresh lease must be acquired from the pool.

Implementations§

Source§

impl LeanWorkerSessionLease<'_>

Source

pub fn session_key(&self) -> &LeanWorkerSessionKey

Return the session key that justified this lease.

Source

pub fn runtime_metadata(&self) -> LeanWorkerRuntimeMetadata

Return protocol/runtime facts reported by the leased worker child.

Source

pub fn is_valid(&self) -> bool

Return whether this lease can still run commands.

Source

pub fn snapshot(&self) -> LeanWorkerPoolSnapshot

Return an operational snapshot for the worker entry behind this lease.

This is the sampling hook to use while a lease is checked out. It keeps child identity, pipe state, and protocol details hidden; the snapshot only reports the same aggregate counters as LeanWorkerPool::snapshot for the leased entry.

Source

pub fn cycle(&mut self) -> Result<(), LeanWorkerError>

Explicitly cycle the leased worker and invalidate this lease.

Acquire a fresh lease before running more work. The pool keeps the restarted child available for compatible future leases.

§Errors

Returns LeanWorkerError if the lease was already invalid or the underlying worker cannot be cycled.

Source

pub fn set_request_timeout( &mut self, timeout: Duration, ) -> Result<(), LeanWorkerError>

Set the request timeout for commands run through this lease.

The pool and supervisor still own the watchdog, child kill, and restart bookkeeping. This method only selects the deadline for subsequent leased requests.

§Errors

Returns LeanWorkerError if the lease was already invalidated.

Source

pub fn run_json_command<Req, Resp>( &mut self, command: &LeanWorkerJsonCommand<Req, Resp>, request: &Req, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<Resp, LeanWorkerError>
where Req: Serialize, Resp: DeserializeOwned,

Run a typed non-streaming downstream JSON command through this lease.

§Errors

Returns LeanWorkerError for invalidated leases, session startup failures, typed command errors, cancellation, timeout, child failure, progress panic, or protocol failure.

Source

pub fn run_streaming_command<Req, Row, Summary>( &mut self, command: &LeanWorkerStreamingCommand<Req, Row, Summary>, request: &Req, rows: &dyn LeanWorkerTypedDataSink<Row>, diagnostics: Option<&dyn LeanWorkerDiagnosticSink>, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerTypedStreamSummary<Summary>, LeanWorkerError>
where Req: Serialize, Row: DeserializeOwned, Summary: DeserializeOwned,

Run a typed downstream streaming command through this lease.

§Errors

Returns LeanWorkerError for invalidated leases, row or summary decode errors, sink failures, cancellation, timeout, child failure, or protocol failure.

Trait Implementations§

Source§

impl<'pool> Debug for LeanWorkerSessionLease<'pool>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for LeanWorkerSessionLease<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'pool> Freeze for LeanWorkerSessionLease<'pool>

§

impl<'pool> RefUnwindSafe for LeanWorkerSessionLease<'pool>

§

impl<'pool> Send for LeanWorkerSessionLease<'pool>

§

impl<'pool> Sync for LeanWorkerSessionLease<'pool>

§

impl<'pool> Unpin for LeanWorkerSessionLease<'pool>

§

impl<'pool> UnsafeUnpin for LeanWorkerSessionLease<'pool>

§

impl<'pool> !UnwindSafe for LeanWorkerSessionLease<'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<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> 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