pub struct NodeHandle {
pub instance_id: NodeId,
pub gossip_addr: String,
pub controller: Arc<ClusterController>,
/* private fields */
}Expand description
One instance of the mini-cluster: a gossip discovery + controller.
Fields§
§instance_id: NodeIdThis node’s identity.
gossip_addr: StringGossip address this node listens on.
controller: Arc<ClusterController>The cluster control facade. Arc-shared so tests can observe
leader status while the harness retains ownership.
Implementations§
Source§impl NodeHandle
impl NodeHandle
Sourcepub async fn kill(self)
pub async fn kill(self)
Gracefully stop this node. Before shutting down the gossip
socket, publishes state = Left via chitchat so peers see the
status change via the next gossip round (~100 ms), rather than
waiting for phi-accrual to flag the missing heartbeats.
This matches the contract other production gossip stacks
(Serf, Akka cluster) provide — clean leave is a protocol
primitive, not a timing hack. Tests that want to simulate a
crash (no clean leave) should use Self::crash instead.
Sourcepub async fn crash(self)
pub async fn crash(self)
Simulate a crash: shut down this node without announcing a
Left state. Peers rely on phi-accrual to eventually detect the
failure, which in the default chitchat config can take tens of
seconds — exactly the behavior a real crash produces. Use
Self::kill for scenarios that expect prompt failover.
Unlike a plain drop, this calls discovery.stop().await to
shut down the chitchat background task and release the UDP
socket. Skipping that was previously leaking tasks and ports
between crash-based tests; the protocol-visible behavior
matches a real crash either way because stop does not emit
any Left announcement (that’s kill’s job).
Auto Trait Implementations§
impl Freeze for NodeHandle
impl !RefUnwindSafe for NodeHandle
impl Send for NodeHandle
impl Sync for NodeHandle
impl Unpin for NodeHandle
impl UnsafeUnpin for NodeHandle
impl !UnwindSafe for NodeHandle
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