MultiNodeRaftNetwork

class MultiNodeRaftNetwork(maxPayloadBytes: Int? = null)

An in-process RaftTransport network backed by Channels — the published equivalent of the :kuilt-raft private test network. Obtain a per-node transport via transport; control network partitions via partition, dropLink, and heal.

Designed for use with MultiNodeRaftSim: call MultiNodeRaftSim.network to reach this instance rather than constructing it directly unless you need manual wiring.

Partition control

  • partition — drop all messages in both directions between two sets of nodes.

  • dropLink — drop messages from one node to another (unidirectional).

  • heal — restore all links (clear every drop rule).

Dropped messages are silently discarded; no error is delivered to the sender. This mirrors real network behaviour where a partitioned peer is simply unreachable.

Parameters

maxPayloadBytes

Reported to the engine via RaftTransport.maxPayloadBytes. null (default) means unbounded. A small value forces us.tractat.kuilt.raft.Committed.Install snapshot chunking to span multiple messages — useful for exercising the chunk-reassembly path.

Constructors

Link copied to clipboard
constructor(maxPayloadBytes: Int? = null)

Functions

Link copied to clipboard
suspend fun deliver(from: NodeId, to: NodeId, bytes: ByteArray)

Inject bytes from from directly into to's channel, bypassing all partition and drop rules. Used in edge-case tests that need to deliver a specific crafted message regardless of current partition state.

Link copied to clipboard
fun dropLink(from: NodeId, to: NodeId)

Drop all messages from from to to (unidirectional).

Link copied to clipboard
fun heal()

Restore all links — clear every drop and partition rule.

Link copied to clipboard
fun partition(a: Set<NodeId>, b: Set<NodeId>)

Partition nodes into two groups — messages in both directions between any node in a and any node in b are silently dropped.

Link copied to clipboard

Return a RaftTransport for id, registering it with the network so other nodes can send to it. Call once per node before constructing us.tractat.kuilt.raft.RaftNode.