pub trait RaftNetworkFactory<C>: Send + Sync + 'staticwhere
    C: RaftTypeConfig,{
    type Network: RaftNetwork<C>;

    // Required method
    fn new_client<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        target: C::NodeId,
        node: &'life1 C::Node
    ) -> Pin<Box<dyn Future<Output = Self::Network> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait defining the interface for a Raft network factory to create connections between cluster members.

See the network chapter of the guide for details and discussion on this trait and how to implement it.

Typically, the network implementation as such will be hidden behind a Box<T> or Arc<T> and this interface implemented on the Box<T> or Arc<T>.

Required Associated Types§

source

type Network: RaftNetwork<C>

Actual type of the network handling a single connection.

Required Methods§

source

fn new_client<'life0, 'life1, 'async_trait>( &'life0 mut self, target: C::NodeId, node: &'life1 C::Node ) -> Pin<Box<dyn Future<Output = Self::Network> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new network instance sending RPCs to the target node.

This function should not create a connection but rather a client that will connect when required. Therefore there is chance it will build a client that is unable to send out anything, e.g., in case the Node network address is configured incorrectly. But this method does not return an error because openraft can only ignore it.

The method is intentionally async to give the implementation a chance to use asynchronous sync primitives to serialize access to the common internal object, if needed.

Implementors§