pub struct SimNetwork { /* private fields */ }Expand description
In-memory message fabric shared by every SimTransport in a cluster, and
the control handle a test uses to inject faults. A drop-in for
HttpLoopback via ClusterBuilder::transport that additionally lets a
test partition links and heal them.
Clone is a shared handle (an Arc inside): the copy a test keeps and the
copies inside each peer’s transport all see the same fabric.
Implementations§
Source§impl SimNetwork
impl SimNetwork
Sourcepub fn partition(&self, a: &Address, b: &Address)
pub fn partition(&self, a: &Address, b: &Address)
Drop all traffic between a and b in both directions until heal.
A send across a blocked link fails as a connection error, so an
auto-sync peer’s queued entries stay pending and redeliver after heal —
a message-level partition, finer than withholding exchange calls.
Sourcepub fn heal(&self, a: &Address, b: &Address)
pub fn heal(&self, a: &Address, b: &Address)
Restore traffic between a and b (both directions).
Sourcepub fn set_manual_delivery(&self, manual: bool)
pub fn set_manual_delivery(&self, manual: bool)
Capture SendEntries pushes instead of delivering them inline (true),
or return to inline delivery (false). Flip this after setup
(bootstrap / auto_sync) so only the entry pushes a test cares about get
captured. Turning it back off does not flush the queue — already-captured
messages still need an explicit deliver.
The two fault families compose with partition taking precedence: a
send across a partitioned link fails as a connection
error before capture is considered, so it parks in the retry queue rather
than the in-flight queue. Manual delivery only ever captures pushes on
links that are up. Tests generally use one family or the other, not both at
once.
Sourcepub fn pending(&self) -> Vec<usize>
pub fn pending(&self) -> Vec<usize>
The delivery handles of every captured-but-undelivered message, in the
order they were sent. Pass these to deliver,
duplicate or drop_message to
drive an out-of-order, duplicated, or lossy schedule.
Sourcepub async fn deliver(&self, seq: usize) -> bool
pub async fn deliver(&self, seq: usize) -> bool
Deliver the captured message seq to its receiver and remove it from the
queue. Delivering in an order other than pending
returned is how a test reorders the wire. Returns false if no such
message is queued (or its receiver has stopped).
Sourcepub async fn deliver_one(&self) -> bool
pub async fn deliver_one(&self) -> bool
Deliver the oldest captured message. Returns false when the queue is
empty.
Sourcepub async fn deliver_all(&self) -> usize
pub async fn deliver_all(&self) -> usize
Deliver every captured message in send order, draining the queue. Returns the number delivered. (Delivery never enqueues more — the receiver’s handler processes entries, it doesn’t push back through this fabric.)
Sourcepub fn duplicate(&self, seq: usize) -> Option<usize>
pub fn duplicate(&self, seq: usize) -> Option<usize>
Clone captured message seq so it will be delivered a second time,
modelling a duplicate on the wire. The copy gets a fresh handle and lands
at the back of the queue; the original stays put. Returns the new handle,
or None if seq isn’t queued. Idempotent sync must converge regardless.
Sourcepub fn drop_message(&self, seq: usize) -> bool
pub fn drop_message(&self, seq: usize) -> bool
Drop captured message seq without delivering it — a lost packet.
Returns true if a message was removed.
Trait Implementations§
Source§impl Clone for SimNetwork
impl Clone for SimNetwork
Source§fn clone(&self) -> SimNetwork
fn clone(&self) -> SimNetwork
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for SimNetwork
impl Default for SimNetwork
Source§fn default() -> SimNetwork
fn default() -> SimNetwork
Auto Trait Implementations§
impl Freeze for SimNetwork
impl RefUnwindSafe for SimNetwork
impl Send for SimNetwork
impl Sync for SimNetwork
impl Unpin for SimNetwork
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more