Quilter

constructor(replica: ReplicaId, seam: Seam, initial: S, messageSerializer: KSerializer<QuiltMessage<S>>, scope: CoroutineScope, config: QuilterConfig = QuilterConfig(), clock: MonotonicMillis = SystemMonotonicMillis, binaryFormat: BinaryFormat = Cbor, deltaTargets: (Set<PeerId>) -> Set<PeerId> = { it }, random: Random = kotlin.random.Random.Default)

Parameters

replica

this peer's ReplicaId.

seam

the Seam to ride. Collect Seam.incoming exactly once — this class takes sole ownership of the incoming stream.

initial

the starting state (typically the CRDT's zero/empty value).

messageSerializer

a KSerializer for QuiltMessage<S>, obtained via QuiltMessage.serializer(stateSerializer).

scope

the CoroutineScope whose Job becomes the parent of the replicator's owned child job. In tests, pass backgroundScope from kotlinx.coroutines.test.TestScope so infinite-running collectors are cancelled cleanly at test end without raising kotlinx.coroutines.test.UncompletedCoroutinesError.

config

replication behaviour tuning (eviction TTL, anti-entropy interval).

clock

monotonic time source; override in tests to inject a fake clock.

Test-dispatcher guard. If the scope contains a kotlinx.coroutines.test.TestDispatcher, a diagnostic is emitted because runAntiEntropy uses real-clock kotlinx.coroutines.delay — under virtual time those delays never advance automatically, causing tests to deadlock silently. Either use UnconfinedTestDispatcher (delays execute eagerly) or advance virtual time via testScheduler.advanceTimeBy(…) if you must use StandardTestDispatcher. Set QuilterConfig.strictTestGuard to true to throw rather than warn.