ClusterClient

A Raft learner-client that proposes commands through the cluster leader and exposes the committed log stream for state-machine application.

Obtain an instance via clusterClientWithNode (tests / caller-managed transport) or via the CoroutineScope.clusterClient extension (production relay-room usage, available in S3b once the Seam-reconnect transport adapter is wired).

Exactly-once proposals

propose (no-arg overload) delegates to RaftNode.propose, which draws a monotonic requestId internally, in memory, for this incarnation only. It is refused under ClientIdentity.Durable.

propose with an explicit requestId is the public cross-crash exactly-once overload: callers that persist a requestId and replay it after a crash get at-most-once application of the command, via us.tractat.kuilt.raft.ClientSessionTable.shouldApply.

Failover model (S3a API contract; S3b wires the production path)

On transport tear the underlying ServerClusterReconnect advances to the next endpoint. The new server holds no seat for the client's device key — each server keeps its seats and reconnect windows in memory — so it admits the client as a new member: a cross-server reconnect is always a fresh join, not an error.

See also

for the test / caller-managed-transport construction path.

Properties

Link copied to clipboard
val committed: Flow<Committed>

The committed log stream — collect this to apply state-machine entries.

Link copied to clipboard
val role: StateFlow<RaftRole>

The Raft role this client node holds (always RaftRole.Learner in the relay model).

Functions

Link copied to clipboard
suspend fun close()

Close this client and end its connection: no further dials reach the fabric, the room it joined has been left, and the relay transport's pumps have stopped. Idempotent.

Link copied to clipboard
suspend fun propose(command: ByteArray): LogEntry

Proposes command with an auto-minted, monotonic requestId.

suspend fun propose(command: ByteArray, requestId: Long): LogEntry

Proposes command with a caller-pinned requestId for cross-crash exactly-once dedup.