class
Raft::Transport::InMemory
- Raft::Transport::InMemory
- Raft::Transport
- Reference
- Object
Overview
In-memory transport for testing.
Messages are delivered directly between fibers via a class-level channel
registry — no sockets involved. Supports partition simulation via
.partition / .heal class methods.
Call .reset between test cases to clear all registrations and partitions.
Defined in:
raft/transport/in_memory.crConstructors
Class Method Summary
-
.heal(a : String, b : String) : Nil
Removes the partition between nodes a and b, restoring connectivity.
-
.partition(a : String, b : String) : Nil
Simulates a network partition between nodes a and b (bidirectional).
-
.reset : Nil
Clears all registrations and partitions.
Instance Method Summary
-
#send(peer_id : String, message : RPC::Message) : Nil
Sends an RPC message to the peer identified by peer_id.
-
#start(inbox : Channel(RPC::Envelope)) : Nil
Starts listening for incoming messages.
-
#stop : Nil
Shuts down the transport, closing all connections and listeners.
Instance methods inherited from class Raft::Transport
send(peer_id : String, message : RPC::Message) : Nil
send,
start(inbox : Channel(RPC::Envelope)) : Nil
start,
stop : Nil
stop
Constructor Detail
Class Method Detail
Removes the partition between nodes a and b, restoring connectivity.
Simulates a network partition between nodes a and b (bidirectional).
Instance Method Detail
Sends an RPC message to the peer identified by peer_id.
Delivery is best-effort. If the peer is unreachable the message is silently dropped — Raft's protocol-level retries handle the loss.
Starts listening for incoming messages.
Received messages are wrapped in RPC::Envelope (tagged with sender ID)
and pushed into the provided inbox channel.
Shuts down the transport, closing all connections and listeners.