Skip to main content
Version: 0.9.0

Streams to clients

A stream flows from a Plugin unit to the Core on a transport of its own (streams and transports). This page is the other half: how its data reaches a client.

Two acts, and they are not the same one​

ActMeansWho else it affects
stream.startmake the stream flow at all — the Core activates it on the unit's Session and the unit begins emittingeveryone: a stream is a property of the unit, not of the client that asked
stream.subscribedeliver a copy of what is flowing to this clientnobody 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 channelThe deliveryThe client
local, bound as a local socketa per-subscriber socket at plugins/<unit>/subscribers/<stream>/<n>.sock, created when the subscription is granted; the Core listens and the client connectsis on the host, and can open it
local, bound on a loopback or routable addressstream-delivery frames on the channel's own connection, apart from the control shapecannot reach a path in the instance's tree
http+wsone binary WebSocket for this stream, at the path the answer namesspeaks nothing else
  • The answer to stream.subscribe says 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 identityone delivery carries one stream
the sequence, unchangeda gap means loss, a decrease means reorder
the sender's clock at emissiona consumer plotting against time uses the instrument's moment
the payload, opaquethe 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​

CauseThe deliveryThe client learns
stream.unsubscribereleased, and what carried it removedfrom the answer
the channel detachesreleased with everything the connection heldnothing — it is gone
the unit's Session endsreleased: the Session takes every stream with itunit.state.changed, and unit.stream.stopped
the instance stopschannels drain, and everything is releasedinstance.stopping
the stream is stopped — by this client, another, or an administrative callerkept, carrying nothingunit.stream.stopped, with the reason
the channel is suspended darkkept, delivering nothing until channel.resumedchannel.suspended
the client falls behind — more than 1024 frames held for itreleased; no frame is ever dropped from itits 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.