pub struct ClusterSupervisor<L: PeerLiveness, A: ShardAdopter> { /* private fields */ }Expand description
Watches peer liveness and auto-adopts a dead peer’s shards (SS-5b).
Implementations§
Source§impl<L: PeerLiveness, A: ShardAdopter> ClusterSupervisor<L, A>
impl<L: PeerLiveness, A: ShardAdopter> ClusterSupervisor<L, A>
Sourcepub fn new(
liveness: Arc<L>,
adopter: Arc<A>,
peers: Vec<WatchedPeer>,
config: SupervisorConfig,
) -> Self
pub fn new( liveness: Arc<L>, adopter: Arc<A>, peers: Vec<WatchedPeer>, config: SupervisorConfig, ) -> Self
Build a supervisor over peers, polling liveness and calling
adopter.adopt_shards on confirmed peer death. Peers with no owned shards
are dropped from the watch set (nothing to adopt for them).
Sourcepub fn with_publisher(
self,
publisher: Arc<ClusterEventPublisher>,
self_node: impl Into<String>,
) -> Self
pub fn with_publisher( self, publisher: Arc<ClusterEventPublisher>, self_node: impl Into<String>, ) -> Self
Attach the WS3 cluster-event publisher and this node’s name so tick()
emits topology deltas. Pure builder addition — a supervisor without it
behaves exactly as before (every existing test passes new only).
Sourcepub fn watches_any(&self) -> bool
pub fn watches_any(&self) -> bool
Whether this supervisor watches any peer (false when no peer declared owned shards — the loop would do nothing, so the caller can skip spawning).
Sourcepub fn adopter(&self) -> &A
pub fn adopter(&self) -> &A
Borrow the adopter (the engine, in production) this supervisor drives. Lets a test inspect the engine it auto-adopts onto after the loss.
Sourcepub async fn tick(&mut self) -> Vec<String>
pub async fn tick(&mut self) -> Vec<String>
Run ONE poll tick: observe every watched peer’s liveness, advance the
debounce counters, and adopt the shards of any peer that has now been down
for confirmations consecutive ticks and is not yet adopted.
Returned is the list of peer names adopted on THIS tick (empty on a quiet tick), so a test can assert exactly when adoption fires. Extracted from the loop so the debounce decision is unit-testable without real time.
Auto Trait Implementations§
impl<L, A> !RefUnwindSafe for ClusterSupervisor<L, A>
impl<L, A> !UnwindSafe for ClusterSupervisor<L, A>
impl<L, A> Freeze for ClusterSupervisor<L, A>
impl<L, A> Send for ClusterSupervisor<L, A>
impl<L, A> Sync for ClusterSupervisor<L, A>
impl<L, A> Unpin for ClusterSupervisor<L, A>
impl<L, A> UnsafeUnpin for ClusterSupervisor<L, A>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request