CompositeLoom

class CompositeLoom(plies: StateFlow<List<Pair<PlyId, Loom>>>, dispatcher: CoroutineContext = Dispatchers.Default) : 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.

Constructors

Link copied to clipboard
constructor(plies: StateFlow<List<Pair<PlyId, Loom>>>, dispatcher: CoroutineContext = Dispatchers.Default)
constructor(plies: List<Pair<PlyId, Loom>>, dispatcher: CoroutineContext = Dispatchers.Default)

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

Functions

Link copied to clipboard
open override fun availability(): FabricAvailability

Whether this fabric can be attempted now. Default FabricAvailability.Available; fabrics gated on a runtime capability override.

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

Establish a Seam according to rendezvous — either host a new session or join an existing one.