SeamRoomFactory

class SeamRoomFactory(loom: Loom, scope: CoroutineScope, clock: () -> Instant, heartbeatConfig: HeartbeatConfig = HeartbeatConfig()) : RoomFactory

Loom-backed implementation of RoomFactory.

Each call to host or join weaves a new Seam via loom, wraps it in a SeamRoom, and drives the admit/identify handshake:

scope is used to launch the per-Room admit loop coroutines. Callers should use a scope whose lifetime matches the room's intended lifetime (e.g. backgroundScope in tests, a structured session scope in production).

SeamRoom's internal membership state is guarded by a reentrant lock and is safe under any dispatcher, including multi-threaded ones such as Dispatchers.Default. Suspend calls (sends, broadcasts) are always performed outside the lock.

clock is required (not defaulted) so callers must make an explicit choice: use SeamRoomFactory.systemClock for production wall-clock time or supply a virtual clock in tests. An accidental epoch-zero default would ship wrong timestamps silently.

heartbeatConfig controls partition-detection timing.

See also

for the production convenience constructor.

Constructors

Link copied to clipboard
constructor(loom: Loom, scope: CoroutineScope, clock: () -> Instant, heartbeatConfig: HeartbeatConfig = HeartbeatConfig())

Types

Link copied to clipboard
object Companion

Functions

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

Host a new room. The caller's peer becomes the SessionRole.Host.

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

Join an existing room. The caller's peer becomes a SessionRole.Joiner.