Expand description
Wire pieces for subscriptions.
r[impl jetstream.subscription.overview] A subscription is a streaming response: one request, many responses sharing its tag, terminated explicitly. This module carries the three things that shape needs on the wire and nothing else — the terminator, cancellation, and the endpoint identifier. The client and server plumbing that uses them lands separately.
Structs§
- Cancellation
Token - A token which can be used to signal a cancellation request to one or more tasks.
- Cancelled
- The producer stopped because its subscriber did.
- Endpoint
- r[impl jetstream.lane.addressing] The endpoint a subscription addresses within a peer — the room, the object, the cell. An opaque byte string: codegen emits the client that carries it and cannot know an application’s naming, so any structure is the application’s to impose and no implementation’s to interpret.
- Items
- The served side of a subscription: what the producer writes into.
- Labelled
- A subscription that says which one it is.
Unpin, so it goes straight intoselect_all. - Producer
- r[impl jetstream.subscription.surface.producer]
The producer’s end. It can send, and it can learn — which is the
half a bare
Sendercannot do, and the reason a producer loop written against one compiles, runs, and keeps inferring long after the subscriber has gone. - Rcancel
- r[impl jetstream.subscription.cancel]
The acknowledgement, which
r[jetstream.subscription.cancel]requires to arrive on the subscription’s own lane after every item already emitted there — that ordering is what makes the tag safe to reuse. - Subscription
- r[impl jetstream.subscription.surface] The caller’s end of a subscription, in the types the caller declared.
- Tcancel
- r[impl jetstream.subscription.cancel]
Cancellation bears a fresh tag and names its target in the
payload, which is the shape 9P’s
Tflushuses and the one this specification adopted after an earlier draft got the mechanics backwards. Sending it under the subscription’s own tag would put two calls under one correlation key while that tag is still in flight. - Terminator
- r[impl jetstream.subscription.termination] A terminator that carries a typed value names the method it ends.
Enums§
- Item
- r[impl jetstream.subscription.surface.terminal-value] r[impl jetstream.subscription.surface.composition] What a subscription yields. The end is a value in the sequence, not the absence of one.
Constants§
- RCANCEL
- r[impl jetstream.subscription.cancel]
- RDONE
- r[impl jetstream.subscription.compat]
The terminator, and cancellation, take global message ids in the
space below
MESSAGE_ID_START, exactly asRJETSTREAMERRORalready does. That is what keeps102 + 2 * indexintact: a streaming method costs no extra per-method id, sor[jetstream.rpc.swift.message-ids]andr[jetstream.rpc.ts.message-ids]do not change and no protocol is re-generated for its unary methods. - TCANCEL
- r[impl jetstream.subscription.cancel]
Functions§
- channel
- r[impl jetstream.subscription.surface.producer]
The producer/consumer pair for one subscription.
cancelis the dispatcher’s token, so cancelling the subscription cancels the work. - merge
- r[impl jetstream.subscription.surface.composition] Merge many subscriptions without losing which one ended, or with what. Fan-in — use case 2 — and a terminal value — use case 4 — are each easy alone; this is the combination the document listed separately and never checked.
Type Aliases§
- Item
Stream - The boxed sequence a
Subscriptionreads: items, then the end.