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<'_>
impl LeanWorkerSessionLease<'_>
Sourcepub fn session_key(&self) -> &LeanWorkerSessionKey
pub fn session_key(&self) -> &LeanWorkerSessionKey
Return the session key that justified this lease.
Sourcepub fn runtime_metadata(&self) -> LeanWorkerRuntimeMetadata
pub fn runtime_metadata(&self) -> LeanWorkerRuntimeMetadata
Return protocol/runtime facts reported by the leased worker child.
Sourcepub fn snapshot(&self) -> LeanWorkerPoolSnapshot
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.
Sourcepub fn cycle(&mut self) -> Result<(), LeanWorkerError>
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.
Sourcepub fn set_request_timeout(
&mut self,
timeout: Duration,
) -> Result<(), LeanWorkerError>
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.
Sourcepub 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,
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.
Sourcepub 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>
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>
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.