pub struct GroupStateMachine { /* private fields */ }Expand description
State machine for managing group steward epoch flow.
Implementations§
Source§impl GroupStateMachine
impl GroupStateMachine
Sourcepub fn new_as_member() -> Self
pub fn new_as_member() -> Self
Create a new group state machine (not steward) with default config.
Sourcepub fn new_as_member_with_config(config: GroupConfig) -> Self
pub fn new_as_member_with_config(config: GroupConfig) -> Self
Create a new group state machine (not steward) with custom config.
Sourcepub fn new_as_steward() -> Self
pub fn new_as_steward() -> Self
Create a new group state machine as steward with default config.
Sourcepub fn new_as_steward_with_config(config: GroupConfig) -> Self
pub fn new_as_steward_with_config(config: GroupConfig) -> Self
Create a new group state machine as steward with custom config.
Sourcepub fn new_as_pending_join() -> Self
pub fn new_as_pending_join() -> Self
Create a new group state machine in PendingJoin state with default config.
Sourcepub fn new_as_pending_join_with_config(config: GroupConfig) -> Self
pub fn new_as_pending_join_with_config(config: GroupConfig) -> Self
Create a new group state machine in PendingJoin state with custom config.
Sourcepub fn current_state(&self) -> GroupState
pub fn current_state(&self) -> GroupState
Get the current state.
Sourcepub fn is_steward(&self) -> bool
pub fn is_steward(&self) -> bool
Check if this is a steward state machine.
Sourcepub fn set_steward(&mut self, is_steward: bool)
pub fn set_steward(&mut self, is_steward: bool)
Set steward status.
Sourcepub fn start_working(&mut self)
pub fn start_working(&mut self)
Start working state.
Sourcepub fn start_waiting(&mut self)
pub fn start_waiting(&mut self)
Start waiting state.
Sourcepub fn start_leaving(&mut self)
pub fn start_leaving(&mut self)
Transition to Leaving state.
Caller must ensure valid state transition (typically from Working or Waiting).
The User::leave_group method handles PendingJoin and Leaving states separately.
Sourcepub fn is_pending_join_expired(&self) -> bool
pub fn is_pending_join_expired(&self) -> bool
Check if the pending join has expired (time-based).
Expiration happens when ~2 epoch durations have passed since join attempt. If the member hasn’t received a welcome by then, assume rejection.
Sourcepub fn is_commit_timed_out(&self) -> bool
pub fn is_commit_timed_out(&self) -> bool
Check if the commit has timed out while in Waiting state.
Returns true if the member has been in Waiting for longer than
epoch_duration / 2 without receiving a commit from the steward.
Sourcepub fn sync_epoch_boundary(&mut self)
pub fn sync_epoch_boundary(&mut self)
Sync the epoch boundary to now. Called when a commit or welcome (for joining) is received. This is the synchronization point between steward and member epochs.
Sourcepub fn check_epoch_boundary(&mut self, approved_proposals_count: usize) -> bool
pub fn check_epoch_boundary(&mut self, approved_proposals_count: usize) -> bool
Check if we’ve reached the expected epoch boundary and should enter Waiting.
Called by the member epoch timer. Returns true if entering Waiting state
(meaning a commit timeout should be started).
§Arguments
approved_proposals_count- Number of approved proposals waiting for commit
§Returns
true if transitioned to Waiting state, false otherwise.
Sourcepub fn time_until_next_boundary(&self) -> Option<Duration>
pub fn time_until_next_boundary(&self) -> Option<Duration>
Get the time until the next expected epoch boundary.
Returns None if no epoch boundary has been set yet.
Sourcepub fn start_steward_epoch(&mut self) -> Result<(), StateMachineError>
pub fn start_steward_epoch(&mut self) -> Result<(), StateMachineError>
Trait Implementations§
Source§impl Clone for GroupStateMachine
impl Clone for GroupStateMachine
Source§fn clone(&self) -> GroupStateMachine
fn clone(&self) -> GroupStateMachine
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GroupStateMachine
impl Debug for GroupStateMachine
Auto Trait Implementations§
impl Freeze for GroupStateMachine
impl RefUnwindSafe for GroupStateMachine
impl Send for GroupStateMachine
impl Sync for GroupStateMachine
impl Unpin for GroupStateMachine
impl UnwindSafe for GroupStateMachine
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,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
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> 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