pub trait ElectionClient:
Send
+ Sync
+ 'static {
// Required methods
fn id(&self) -> MetaResult<String>;
fn run_once<'life0, 'async_trait>(
&'life0 self,
ttl: i64,
stop: Receiver<()>,
) -> Pin<Box<dyn Future<Output = MetaResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe(&self) -> Receiver<bool>;
fn leader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MetaResult<Option<ElectionMember>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_members<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MetaResult<Vec<ElectionMember>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_leader(&self) -> bool;
// Provided method
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MetaResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
Required Methods§
fn id(&self) -> MetaResult<String>
sourcefn run_once<'life0, 'async_trait>(
&'life0 self,
ttl: i64,
stop: Receiver<()>,
) -> Pin<Box<dyn Future<Output = MetaResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run_once<'life0, 'async_trait>(
&'life0 self,
ttl: i64,
stop: Receiver<()>,
) -> Pin<Box<dyn Future<Output = MetaResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the long-running election process.
Returns when the leader status is lost, or the stop signal is received.