risingwave_meta::rpc::election

Trait ElectionClient

source
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§

source

fn id(&self) -> MetaResult<String>

source

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.

source

fn subscribe(&self) -> Receiver<bool>

source

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,

source

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,

source

fn is_leader(&self) -> bool

Provided Methods§

source

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

Implementors§