Skip to main content

PeerSender

Trait PeerSender 

Source
pub trait PeerSender: Send + Sync {
    // Required method
    fn send<'life0, 'async_trait>(
        &'life0 self,
        peer: NodeId,
        api_key: i16,
        body: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, RaftError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn probe_kraft_version<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _address: &'life1 str,
        _finalized_version: u16,
    ) -> Pin<Box<dyn Future<Output = Result<bool, RaftError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn update_voters(&self, _voters: &VoterSet) { ... }
    fn discovery_peers(&self) -> Vec<NodeId> { ... }
    fn remember_leader_endpoint(&self, _leader: NodeId, _address: String) { ... }
}
Expand description

Outbound peer RPC sender.

It encodes nothing itself. The event loop hands it the already-encoded request body (see wire) and the destination peer. The impl then dials the peer, sends the body, and returns the raw response body.

This matches the async_trait mechanism that OutboundDialer uses.

Required Methods§

Source

fn send<'life0, 'async_trait>( &'life0 self, peer: NodeId, api_key: i16, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Bytes, RaftError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends body, a request for api_key, to peer and returns the raw response body.

§Errors

Returns RaftError if the peer is unreachable or the RPC fails.

Provided Methods§

Source

fn probe_kraft_version<'life0, 'life1, 'async_trait>( &'life0 self, _address: &'life1 str, _finalized_version: u16, ) -> Pin<Box<dyn Future<Output = Result<bool, RaftError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Probe an advertised candidate endpoint through the configured outbound security dialer and verify its finalized kraft.version support.

Source

fn update_voters(&self, _voters: &VoterSet)

Replace the peer endpoint table after applying a VotersRecord.

Source

fn discovery_peers(&self) -> Vec<NodeId>

Transport-only bootstrap peers used by an observer with no voter view.

Source

fn remember_leader_endpoint(&self, _leader: NodeId, _address: String)

Address leader at address, the host:port it announced in a response’s NodeEndpoints. A voter-set listener for the same node takes precedence.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§