Skip to main content

LeaderElection

Trait LeaderElection 

Source
pub trait LeaderElection: Send + Sync {
    // Required methods
    fn try_become_leader<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, DistributedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_leader(&self) -> bool;
    fn step_down<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), DistributedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Interface for components participating in cluster leader election.

Required Methods§

Source

fn try_become_leader<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, DistributedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempt to become the leader or renew leadership if already the leader.

Source

fn is_leader(&self) -> bool

Returns true if this node is currently the elected leader.

Source

fn step_down<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), DistributedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Step down from leadership explicitly.

Implementors§