pub struct MiniCluster {
pub nodes: Vec<NodeHandle>,
pub rules: Option<Arc<NetworkRules>>,
pub snapshot: Option<Arc<AssignmentSnapshotStore>>,
}Expand description
Builder + wrapper for a set of in-process cluster nodes.
Fields§
§nodes: Vec<NodeHandle>The nodes in ID order: nodes[0] has the lowest
instance_id and is the leader under normal operation.
rules: Option<Arc<NetworkRules>>Shared network rules. None for plain Self::spawn
clusters (default UDP transport); Some when built via
Self::spawn_partitionable.
snapshot: Option<Arc<AssignmentSnapshotStore>>Shared assignment snapshot store handed to every node’s
controller (so a snapshot written by one node is visible to
all). None unless built via Self::spawn_with_snapshot.
Implementations§
Source§impl MiniCluster
impl MiniCluster
Sourcepub async fn spawn(n: usize) -> Self
pub async fn spawn(n: usize) -> Self
Spin up n nodes with the default UDP transport. See
Self::spawn_partitionable for a variant that allows
simulating network partitions.
§Panics
Panics if any chitchat instance fails to start (UDP bind failure, usually indicates port contention).
Sourcepub async fn spawn_partitionable(n: usize) -> Self
pub async fn spawn_partitionable(n: usize) -> Self
Spin up n nodes with a PartitionableTransport wrapping
the default UDP transport. The returned cluster carries
Self::rules so tests can call
NetworkRules::partition / NetworkRules::heal during
the test.
§Panics
Same as Self::spawn.
Sourcepub async fn spawn_with_snapshot(
n: usize,
snapshot: Arc<AssignmentSnapshotStore>,
) -> Self
pub async fn spawn_with_snapshot( n: usize, snapshot: Arc<AssignmentSnapshotStore>, ) -> Self
Spin up n nodes sharing the given
AssignmentSnapshotStore. Each node’s controller is
constructed with the same store, so a snapshot written by
any node is visible to every other node and survives across
a full cluster restart (provided the object store does).
Sourcepub async fn join_node(&mut self, instance_id: NodeId)
pub async fn join_node(&mut self, instance_id: NodeId)
Join one new node with the given instance_id into an
already-running cluster. Seeds from nodes[0] for discovery.
Useful for testing rejoin-after-kill and elastic scale-up
scenarios.
§Panics
Panics if the cluster is empty (nothing to seed from) or if chitchat fails to bind a loopback port.
Sourcepub fn addrs(&self) -> Vec<SocketAddr>
pub fn addrs(&self) -> Vec<SocketAddr>
Parse and collect node gossip addresses — useful for building
partition rules via NetworkRules::partition.
§Panics
Panics if any node’s gossip_addr doesn’t parse as a
SocketAddr (only possible if the MiniCluster was constructed
with malformed input).
Auto Trait Implementations§
impl Freeze for MiniCluster
impl !RefUnwindSafe for MiniCluster
impl Send for MiniCluster
impl Sync for MiniCluster
impl Unpin for MiniCluster
impl UnsafeUnpin for MiniCluster
impl !UnwindSafe for MiniCluster
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§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