CompositeLoom

class CompositeLoom(plies: StateFlow<List<Pair<PlyId, Loom>>>, dispatcher: CoroutineContext = Dispatchers.Default, policy: DeliveryPolicy = DeliveryPolicy.Reliable, onPlyFailure: (PlyReconcileException) -> Unit = {}) : Loom

A Loom that weaves one logical session from several constituent Looms ("plies"). The union of plies covers the session's peer set; the list order is a send-preference hint (most-preferred first).

The ply set may change while the session is live: construct with a StateFlow of the desired set and push a new list to attach or detach plies. Each emission is reconciled against the current live set — new entries are woven in, removed entries are detached. The list constructor is the degenerate case of a never-changing flow.

Parameters

plies

The desired ply set; emit a new value to reconcile (attach/detach).

dispatcher

Forwarded to each CompositeSeam as the scope for its internal coroutines (scheduling only — the woven seam's thread-safety is via a lock + atomics, so it is correct under a multi-threaded dispatcher). Production default (Dispatchers.Default); tests inject a dispatcher derived from the test scheduler.

policy

Governs the inbound us.tractat.kuilt.core.Spool's capacity and overflow behaviour for each woven CompositeSeam. Defaults to DeliveryPolicy.Reliable (bounded, backpressured, lossless).

onPlyFailure

Raised whenever one ply fails inside a live session — a constituent Loom's capability()/weave() or a ply Seam's close() threw while reconciling, or a peer sent an inbound frame the ply could not process. The composite absorbs the failure and keeps going: the other plies still reconcile, a failed attach is retried on the next plies emission, and a ply whose inbound frame failed drops that frame and keeps delivering. kuilt-core is logger-free, so this is how that surfaces to a consumer's own logger. Best-effort and non-suspending; defaults to a silent absorb. See PlyReconcileException.

Constructors

Link copied to clipboard
constructor(plies: StateFlow<List<Pair<PlyId, Loom>>>, dispatcher: CoroutineContext = Dispatchers.Default, policy: DeliveryPolicy = DeliveryPolicy.Reliable, onPlyFailure: (PlyReconcileException) -> Unit = {})
constructor(plies: List<Pair<PlyId, Loom>>, dispatcher: CoroutineContext = Dispatchers.Default, policy: DeliveryPolicy = DeliveryPolicy.Reliable, onPlyFailure: (PlyReconcileException) -> Unit = {})

Static convenience: a fixed ply set that never changes after weave().

Functions

Link copied to clipboard

Whether this fabric can be attempted now — the availability half of capability. Derived; do not override.

Link copied to clipboard
open override fun capability(): TransportCapability

This fabric's role(s) and whether it can be attempted now. The single capability primitive — override this, not availability. Default: a roleless FabricAvailability.Available.

Link copied to clipboard
open suspend fun host(pattern: Pattern): Seam

Host / start a new session.

Link copied to clipboard
open suspend fun join(tag: Tag): Seam

Join an existing session. The advertisement carries enough info to reach the existing peer set.

Link copied to clipboard
open suspend override fun weave(rendezvous: Rendezvous): Seam

Weave every ply in the current desired set and bond them into one Seam.