KtorClientLoom

class KtorClientLoom(httpClient: HttpClient, dispatcher: CoroutineDispatcher = Dispatchers.Default, val selfPeerId: PeerId = PeerId(Uuid.random().toString())) : Loom

Client-side Loom backed by Ktor WebSockets.

join connects directly to a WebSocketAdvertisement URL and returns a 2-peer WebSocketSeam — no intermediate contract Session adapter.

PeerId discovery:

Stable identity across reconnects: supplying selfPeerId gives this loom a fixed fabric identity reused on every call to weave/join. This is required for cluster-client failover: the server derives a learner NodeId from the admitted PeerId; if a reconnect mints a new random id the server admits a different learner and Raft routing breaks. The default mints a fresh random identity per loom instance (mirroring the old per-join behaviour for callers that do not need stable identity). See #544.

HttpClient lifecycle: the httpClient is not closed by this loom. Callers are responsible for closing it when all connections are done.

Parameters

dispatcher

Scheduler for the per-connection seam's read/write loops; the loom confines it to a single thread via limitedParallelism(1). Production default is Dispatchers.Default; tests inject kotlinx.coroutines.test.UnconfinedTestDispatcher.

selfPeerId

The fabric identity this loom presents on every join. Defaults to a random UUID minted once at construction; supply a deterministic value for stable cluster-client identity across reconnects.

Constructors

Link copied to clipboard
constructor(httpClient: HttpClient, dispatcher: CoroutineDispatcher = Dispatchers.Default, selfPeerId: PeerId = PeerId(Uuid.random().toString()))

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open suspend fun host(pattern: Pattern): Seam
Link copied to clipboard
open suspend fun join(tag: Tag): Seam
Link copied to clipboard
open suspend override fun weave(rendezvous: Rendezvous): Seam

Establishes a Seam: