pub struct SessionHandle { /* private fields */ }Expand description
A cloneable operation entry for one Session.
Handles never own the lifecycle: dropping the last handle does not close
the session, and after the owner is dropped they can still read retained
observations and replay an accepted request_key to its original
receipt, while new submissions are refused with SessionError::Closed.
Implementations§
Source§impl SessionHandle
impl SessionHandle
Sourcepub fn id(&self) -> ConversationId
pub fn id(&self) -> ConversationId
The conversation this handle operates on.
Sourcepub fn submit(
&self,
request: SubmitRequest,
) -> Result<WorkReceipt, SessionError>
pub fn submit( &self, request: SubmitRequest, ) -> Result<WorkReceipt, SessionError>
Submit one new work.
Accepts on an idle session, atomically allocates a fresh turn id,
writes the request parts as the turn’s first fact block, and spawns the
worker. Rejections (busy, conflict, capacity, invalid input, closed,
faulted) leave no accepted work behind and do not consume the request
key. Idempotent on request_key + parts: a repeat returns the original
receipt without executing again, even once the owner has closed.
Synchronous: admission never blocks on the runner. Spawning the worker still requires a Tokio runtime context.
§Errors
See SessionError.
Sourcepub fn observe(&self, work: &WorkRef) -> Result<WorkObservation, SessionError>
pub fn observe(&self, work: &WorkRef) -> Result<WorkObservation, SessionError>
Read one work’s current published state.
A paused observation includes the prepared calls needed to construct a resume decision, copied from the same revision. Never blocks on the runner and never mutates the work.
§Errors
SessionError::NotFound if the ref does not belong to this session.
Sourcepub async fn wait(
&self,
work: &WorkRef,
timeout: Duration,
) -> Result<WaitOutcome, SessionError>
pub async fn wait( &self, work: &WorkRef, timeout: Duration, ) -> Result<WaitOutcome, SessionError>
Wait finitely for a work to reach Paused / Finished / Faulted.
Returns as soon as one of those states is observed, or TimedOut with
a consistent snapshot when timeout elapses first; a wakeup is never
lost, and timing out does not change the work’s state.
§Errors
SessionError::NotFound if the ref does not belong to this session.
Sourcepub fn resume(
&self,
work: &WorkRef,
expected_revision: u64,
request_key: String,
request: ResumeRequest,
) -> Result<WorkReceipt, SessionError>
pub fn resume( &self, work: &WorkRef, expected_revision: u64, request_key: String, request: ResumeRequest, ) -> Result<WorkReceipt, SessionError>
Continue a paused work.
Validates the ref, the work’s current paused revision, and the request
against the paused continuation before anything runs: a rejected request
executes nothing and leaves the paused material untouched. On acceptance
the work returns to Running in the same turn id and continues under the
deadline measured from its original acceptance. Idempotent on
request_key + (work, expected_revision, request): a same-key repeat
returns the original receipt without re-executing, while the same key
with a different decision or injection is SessionError::Conflict.
Synchronous: admission never blocks on the runner.
§Errors
SessionError::NotFound for a foreign or unknown ref,
SessionError::NotPaused when the work is not paused,
SessionError::StaleRevision when expected_revision is not the
work’s current paused revision, SessionError::Busy while another work
owns the conversation, SessionError::InvalidResume when the driver
rejects the request, SessionError::Conflict on a key reuse with
different arguments, and SessionError::Closed for a request that is
not a replay after shutdown.
Sourcepub fn resume_receipt(
&self,
work: &WorkRef,
expected_revision: u64,
request_key: &str,
request: &ResumeRequest,
) -> Result<Option<WorkReceipt>, SessionError>
pub fn resume_receipt( &self, work: &WorkRef, expected_revision: u64, request_key: &str, request: &ResumeRequest, ) -> Result<Option<WorkReceipt>, SessionError>
Read the receipt of an already-accepted resume without starting work.
Hosts can resolve a retry before applying their own capacity gate.
Some is the original receipt for exactly these arguments; None
means this session has not accepted the key. Neither outcome changes
the work, consumes the key, nor requires a paused or open session.
A missing record does not reserve admission: a later Self::resume
still performs its atomic replay and state checks.
§Errors
SessionError::Conflict if this key was accepted with a different
work, paused revision, or request.
Sourcepub fn cancel(
&self,
work: &WorkRef,
request_key: String,
) -> Result<CancelReceipt, SessionError>
pub fn cancel( &self, work: &WorkRef, request_key: String, ) -> Result<CancelReceipt, SessionError>
Cancel one work.
Fires the work’s own control token while it runs — a completion that
races the cancel keeps its result — or terminates a paused work in
place, retaining its committed facts and continuation. A work
that already finished is never rewritten. Idempotent on request_key: a
same-key retry returns the original receipt.
Synchronous: admission never blocks on the runner.
§Errors
SessionError::NotFound for a foreign, unknown, or already-cleared
ref, SessionError::Busy while another work owns the conversation,
SessionError::Conflict on a key reuse with a different work, and
SessionError::Closed for a request that is not a replay after
shutdown.
Trait Implementations§
Source§impl Clone for SessionHandle
impl Clone for SessionHandle
Source§fn clone(&self) -> SessionHandle
fn clone(&self) -> SessionHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more