MuxSeam

class MuxSeam(delegate: Seam, scope: CoroutineScope)

N-way multiplexer over a Seam.

Produces independent Seam views — one per channel tag — that share a single upstream collection of delegate's Seam.incoming. This satisfies the kuilt contract that Seam.incoming is single-collection: only MuxSeam ever collects from delegate; each channel view subscribes to the internally-shared flow.

Framing

Every outbound frame is prefixed with a 1-byte channel tag. Every inbound frame is filtered by its first byte and delivered to the matching channel view with the tag byte stripped. Frames with no matching channel are silently discarded.

Late-subscriber semantics

The shared upstream is started with replay = 0. Frames emitted before a channel view begins collecting are not replayed — this is best-effort delivery, suitable for Quilter (which heals gaps via FullState + resend) but not suitable for raw at-least-once consumers.

Channel identity

channel is idempotent: calling it twice with the same tag returns the same Seam instance. Thread-safe: concurrent channel calls are serialised by an internal reentrant lock so the backing map is never raced.

Parameters

delegate

the underlying Seam whose Seam.incoming this class owns.

scope

a CoroutineScope for the shared upstream collector.

Constructors

Link copied to clipboard
constructor(delegate: Seam, scope: CoroutineScope)

Functions

Link copied to clipboard
fun channel(tag: Byte): Seam

Returns a Seam view carrying only frames tagged with tag.