Streams to clients
A stream's data reaches a client on a path of its own, apart from the requests that started it. Starting a stream makes it flow for everyone; subscribing delivers a copy to one client. Which path carries the copy depends on what the client can open: a socket on the host, frames on its own connection, or a WebSocket in a browser. A stream flows from a Plugin unit to the Core on a transport of its own (streams and transports), and this page is the other half: starting and subscribing, the three delivery paths, what each preserves, and what ends a delivery.
Two acts, and they are not the same one
| Act | Means | Who else it affects |
|---|---|---|
stream.start | make the stream flow at all — the Core activates it on the unit's Session and the unit begins emitting | everyone: a stream is a property of the unit, not of the client that asked |
stream.subscribe | deliver a copy of what is flowing to this client | nobody else |
- Subscribing to a stream that is not flowing is legal, and carries nothing until it flows. The answer says whether the stream is flowing, so subscribing first and starting second — the order that misses nothing — is not a race.
- Starting a stream is withdrawn from a suspended channel; subscribing is not (arbitration).
The three delivery paths
What carries a stream to a client is decided by what the client can open, never by what the data means.
| The channel | The delivery | The client |
|---|---|---|
local, bound as a local socket | a per-subscriber socket at plugins/<unit>/subscribers/<stream>/<n>.sock, created when the subscription is granted; the Core listens and the client connects | is on the host, and can open it |
local, bound on a loopback or routable address | stream-delivery frames on the channel's own connection, apart from the control shape | cannot reach a path in the instance's tree |
http+ws | one binary WebSocket for this stream, at the path the answer names | speaks nothing else |
- The answer to
stream.subscribesays where the data will arrive — a path, or the identity of the delivery on the connection the client holds. A client never derives it. - The subscriber's identity is a counter, not a name the client chooses: decimal, zero-padded to 8 digits, unique within that unit and stream for the life of the instance, never reused.
What every path preserves
| Preserved | |
|---|---|
| the stream identity | one delivery carries one stream |
| the sequence, unchanged | a gap means loss, a decrease means reorder |
| the sender's clock at emission | a consumer plotting against time uses the instrument's moment |
| the payload, opaque | the Core transports it and does not interpret it |
A stream that tolerates nothing arrives complete and in order; one that tolerates loss may arrive with gaps, and the sequence is how the client knows which. A delivery never adds a guarantee the producing side did not give, and never removes one it did.
What ends a delivery
| Cause | The delivery | The client learns |
|---|---|---|
stream.unsubscribe | released, and what carried it removed | from the answer |
| the channel detaches | released with everything the connection held | nothing — it is gone |
| the unit's Session ends | released: the Session takes every stream with it | unit.state.changed, and unit.stream.stopped |
| the instance stops | channels drain, and everything is released | instance.stopping |
| the stream is stopped — by this client, another, or an administrative caller | kept, carrying nothing | unit.stream.stopped, with the reason |
| the channel is suspended dark | kept, delivering nothing until channel.resumed | channel.suspended |
| the client falls behind — more than 1024 frames held for it | released; no frame is ever dropped from it | its socket closes, or the delivery completes, ended by the Core |
- A delivery kept across a stop means a client does not have to subscribe again when the stream resumes.
- A client that falls behind reads everything that reached it and then the end, and subscribes again from what flows next. The figure is not declarable.
- Cleanup is the Core's on every route, so a client that crashes mid-stream strands nothing.
Nothing streams from a client into a unit
There is no client-produced stream. Continuous input from an interface reaches a unit as commands — one instruction per value, in the control shape, each acknowledged.