Network abstraction for consensus protocols.
Provides both mock (in-memory) and real (kabel) implementations.
Network abstraction for consensus protocols. Provides both mock (in-memory) and real (kabel) implementations.
Abstract network interface for consensus communication.
Abstract network interface for consensus communication.
(broadcast! this topic message)Broadcast message to all peers on topic. Returns channel that completes when sent.
Broadcast message to all peers on topic. Returns channel that completes when sent.
(close-network! this)Close all connections and cleanup. Returns channel that completes when closed.
Close all connections and cleanup. Returns channel that completes when closed.
(get-peer-count this)Get number of connected peers. Returns channel yielding count.
Get number of connected peers. Returns channel yielding count.
(subscribe! this topic handler)Subscribe to messages on topic. Handler is (fn [message] ...) called for each message. Returns channel that yields subscription handle.
Subscribe to messages on topic. Handler is (fn [message] ...) called for each message. Returns channel that yields subscription handle.
(unsubscribe! this topic handle)Unsubscribe from topic. Returns channel that completes when unsubscribed.
Unsubscribe from topic. Returns channel that completes when unsubscribed.
(create-mock-cluster peer-ids)Create a cluster of interconnected mock networks.
All peers share the same message bus, simulating perfect broadcast network (no partitions, no message loss).
Args: peer-ids - Collection of peer UUIDs
Returns: Map of {peer-id → MockNetwork}
Create a cluster of interconnected mock networks.
All peers share the same message bus, simulating perfect
broadcast network (no partitions, no message loss).
Args:
peer-ids - Collection of peer UUIDs
Returns:
Map of {peer-id → MockNetwork}(create-mock-network peer-id)(create-mock-network peer-id shared-bus)Create an in-memory mock network for testing.
Args: peer-id - UUID for this peer shared-bus - Optional shared bus for multi-peer simulation
Returns: MockNetwork instance
Create an in-memory mock network for testing. Args: peer-id - UUID for this peer shared-bus - Optional shared bus for multi-peer simulation Returns: MockNetwork instance
(find-partition peer-id partitions)Find which partition a peer belongs to.
Args: peer-id - UUID of peer partitions - Vector of peer-id sets
Returns: Set of peers in same partition, or nil if not found
Find which partition a peer belongs to. Args: peer-id - UUID of peer partitions - Vector of peer-id sets Returns: Set of peers in same partition, or nil if not found
(heal-partition networks)Remove partition filter from networks, restoring full connectivity.
Args: networks - Map of {peer-id → MockNetwork}
Returns: Map of {peer-id → MockNetwork} (same instances, partition-filter atoms reset to nil)
Remove partition filter from networks, restoring full connectivity.
Args:
networks - Map of {peer-id → MockNetwork}
Returns:
Map of {peer-id → MockNetwork} (same instances, partition-filter atoms reset to nil)(network-stats network)Get statistics about network activity.
Args: network - MockNetwork instance
Returns: Map with :messages-sent, :messages-received, etc.
Get statistics about network activity. Args: network - MockNetwork instance Returns: Map with :messages-sent, :messages-received, etc.
(remove-message-delay network)Remove message delay from network, restoring instant delivery.
Args: network - MockNetwork
Returns: Network with delay removed
Remove message delay from network, restoring instant delivery. Args: network - MockNetwork Returns: Network with delay removed
(simulate-message-delay network min-ms max-ms)Add random delays to messages (simulates network latency).
Adds delay-ms field to network that causes messages to be delivered after a random delay.
Args: network - MockNetwork min-ms - Minimum delay in milliseconds max-ms - Maximum delay in milliseconds
Returns: Network with delay configuration
Add random delays to messages (simulates network latency). Adds delay-ms field to network that causes messages to be delivered after a random delay. Args: network - MockNetwork min-ms - Minimum delay in milliseconds max-ms - Maximum delay in milliseconds Returns: Network with delay configuration
(simulate-network-partition networks partitions)Simulate network partition by filtering messages.
Creates partitions where peers can only communicate within their partition group. Messages between partitions are dropped.
Args: networks - Map of {peer-id → MockNetwork} partitions - Vector of peer-id sets, e.g. [#{p1 p2} #{p3 p4}]
Returns: Map of {peer-id → MockNetwork} (same instances, partition-filter atoms modified)
Simulate network partition by filtering messages.
Creates partitions where peers can only communicate
within their partition group. Messages between partitions are dropped.
Args:
networks - Map of {peer-id → MockNetwork}
partitions - Vector of peer-id sets, e.g. [#{p1 p2} #{p3 p4}]
Returns:
Map of {peer-id → MockNetwork} (same instances, partition-filter atoms modified)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |