pub struct SimNetwork { /* private fields */ }Expand description
Simulated network for DST.
TigerStyle:
- Deterministic message delivery with configurable delays
- Explicit partitions with heal/partition API
- Fault injection at send/receive boundaries
- Full statistics tracking
Implementations§
Source§impl SimNetwork
impl SimNetwork
Sourcepub fn new(
clock: SimClock,
rng: DeterministicRng,
fault_injector: Arc<FaultInjector>,
) -> Self
pub fn new( clock: SimClock, rng: DeterministicRng, fault_injector: Arc<FaultInjector>, ) -> Self
Create a new simulated network.
TigerStyle: Takes shared fault injector for consistent fault injection.
Sourcepub fn with_latency(self, base_ms: u64, jitter_ms: u64) -> Self
pub fn with_latency(self, base_ms: u64, jitter_ms: u64) -> Self
Sourcepub async fn send(&self, from: &str, to: &str, payload: Bytes) -> bool
pub async fn send(&self, from: &str, to: &str, payload: Bytes) -> bool
Send a message from one node to another.
Returns true if message was queued, false if dropped (partition/fault).
Sourcepub async fn receive(&self, node_id: &str) -> Vec<NetworkMessage>
pub async fn receive(&self, node_id: &str) -> Vec<NetworkMessage>
Receive messages for a node.
Returns all messages that have arrived (delivery time <= current time).
Sourcepub async fn partition(&self, node_a: &str, node_b: &str)
pub async fn partition(&self, node_a: &str, node_b: &str)
Create a network partition between two nodes.
Messages between these nodes will be dropped.
Sourcepub async fn heal(&self, node_a: &str, node_b: &str)
pub async fn heal(&self, node_a: &str, node_b: &str)
Heal a network partition between two nodes.
Sourcepub async fn is_partitioned(&self, node_a: &str, node_b: &str) -> bool
pub async fn is_partitioned(&self, node_a: &str, node_b: &str) -> bool
Check if two nodes are partitioned.
Sourcepub async fn pending_count(&self, node_id: &str) -> usize
pub async fn pending_count(&self, node_id: &str) -> usize
Get count of pending messages for a node.
Sourcepub async fn total_pending(&self) -> usize
pub async fn total_pending(&self) -> usize
Get total pending messages across all nodes.
Auto Trait Implementations§
impl !Freeze for SimNetwork
impl !RefUnwindSafe for SimNetwork
impl Send for SimNetwork
impl !Sync for SimNetwork
impl Unpin for SimNetwork
impl !UnwindSafe for SimNetwork
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more