[][src]Trait blip::MeshService

pub trait MeshService: Send {
    fn accept<'async_trait>(
        self,
        cuts: Subscription
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        Self: 'async_trait
; fn add_metadata<K: Extend<(String, Vec<u8>)>>(&self, _keys: &mut K) { ... } }

A trait that allows individual services access to any accepted membership view-change proposals.

use blip::{MeshService, Subscription};

struct MySvc;

#[blip::async_trait]
impl MeshService for MySvc {
    fn add_metadata<K: Extend<(String, Vec<u8>)>>(&self, keys: &mut K) {
        keys.extend(vec![("key".to_owned(), b"value".to_vec())]);
    }

    async fn accept(self, mut cuts: Subscription) {
        while let Ok(cut) = cuts.recv().await {
            // handle membership change
            let _ = cut.members();
            let _ = cut.joined();
            let _ = cut.kicked();
        }
    }
}

Required methods

fn accept<'async_trait>(
    self,
    cuts: Subscription
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
    Self: 'async_trait, 

Receive accepted view-change proposals.

This method is called once for every MeshService added to a Mesh, and will be polled for the entire period the mesh remains online. Resolving early is fine and does not constitute an error.

Blocking (of the non-async variety) within this future should never happen, and will starve the executor if it does.

If the mesh exits (for any reason), this future will be dropped if it has not yet resolved (which may occur at any yield point).

Loading content...

Provided methods

fn add_metadata<K: Extend<(String, Vec<u8>)>>(&self, _keys: &mut K)

Add service-specific metadata to distribute to other members of the mesh.

Loading content...

Implementors

impl<S: Send> MeshService for GrpcService<S>[src]

Loading content...