class

Raft::MemoryTransport

Inherits Raft::Transport < Reference < Object

In-memory transport backed by IO pipes. Wire format is identical to TCPTransport — specs exercise the same encode/decode and outbox/drain paths that run in production. Per-node: each instance owns one outbox, one dispatcher fiber, and a reader+writer fiber pair for each peer.

Constants

DEFAULT_MAX_PAYLOAD = (64_u32 * 1024_u32) * 1024_u32
DEFAULT_OUTBOX_SIZE = 256
DEFAULT_PEER_OUTBOX = 64

Constructors

new(node_id : NodeID, outbox_size : Int32 = DEFAULT_OUTBOX_SIZE, max_payload : UInt32 = DEFAULT_MAX_PAYLOAD)
Source

Class methods

mesh(node_ids : Array(NodeID)) : Hash(NodeID, MemoryTransport)

Test helper: full-mesh wiring for node_ids. Returns a hash so specs can address transports by node id.

Source
pipe_pair(a_id : NodeID, b_id : NodeID) : Tuple(MemoryTransport, MemoryTransport)

Test helper: create two transports wired by a pair of IO pipes (one per direction). Returns them in the same order as ids.

Source

Instance methods

connect_to(peer_id : NodeID, read : IO, write : IO)

Wire this transport to a peer via an IO pipe pair. Safe to call before or after start — fibers spawn lazily for the peer.

Source
isolated
Source
isolated=(value : Bool)
Source
node_id
Source
outbox
Source
register_channel(group_id : UInt64, channel : Channel(Message))
Source
register_peer(id : NodeID, host : String, port : Int32)

MemoryTransport routes by pipe, not network address — no-op for API parity with TCPTransport.

Source
send(to : NodeID, message : Message)

Synchronous write directly to the peer's pipe. Used by per-peer writer fibers; tests can also call this to bypass the outbox path.

Source
start
Source
stop
Source
unregister_channel(group_id : UInt64)
Source