pub trait Election: Send + Sync {
type Leader;
// Required methods
fn is_leader(&self) -> bool;
fn in_leader_infancy(&self) -> bool;
fn register_candidate<'life0, 'life1, 'async_trait>(
&'life0 self,
node_info: &'life1 MetasrvNodeInfo,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn all_candidates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetasrvNodeInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn campaign<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn leader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Leader>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn resign<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe_leader_change(&self) -> Receiver<LeaderChangeMessage>;
}
Required Associated Types§
Required Methods§
Sourcefn in_leader_infancy(&self) -> bool
fn in_leader_infancy(&self) -> bool
When a new leader is born, it may need some initialization operations (asynchronous), this method tells us when these initialization operations can be performed.
note: a new leader will only return true on the first call.
Sourcefn register_candidate<'life0, 'life1, 'async_trait>(
&'life0 self,
node_info: &'life1 MetasrvNodeInfo,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register_candidate<'life0, 'life1, 'async_trait>(
&'life0 self,
node_info: &'life1 MetasrvNodeInfo,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Registers a candidate for the election.
Sourcefn all_candidates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetasrvNodeInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn all_candidates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetasrvNodeInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets all candidates in the election.
Sourcefn campaign<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn campaign<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Campaign waits to acquire leadership in an election.
Multiple sessions can participate in the election, but only one can be the leader at a time.
Sourcefn leader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Leader>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn leader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Leader>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the leader value for the current election.
Sourcefn resign<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resign<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Releases election leadership so other campaigners may acquire leadership on the election.