Skip to main content

Module lifetime

Module lifetime 

Source
Expand description

Session-scoped lane lifetime.

r[impl jetstream.session.lifetime] A lane must not outlive its session. Each session owns a CancellationToken and hands every lane a child of it; closing the session cancels the parent, and every lane and every handle derived from one observes that. A lane’s stream reports the closure and then ends, and its sink refuses further writes, so a call in flight fails rather than hanging.

A cancellation token rather than a one-shot channel per lane, for three reasons: it is cloneable, so handles other than the lane itself — an crate::session::local::OrderedSender, say — can observe the same closure; a child taken from an already-cancelled parent is born cancelled, which closes the race where a lane is handed out concurrently with close; and a dropped child deregisters itself, so a session that opens many short-lived lanes does not accumulate one entry per lane it has ever opened.

Structs§

LaneGuard
A lane that terminates when its session closes.