pub struct Peer {
conf: Arc<Config>,
budget: Budget,
msgs: Queue<(RetryPolicy, Bytes)>,
retry: DelayQueue,
tx: UnboundedSender<(PublicKey, Bytes, Option<OwnedSemaphorePermit>)>,
countdown: Countdown,
max_message_size: usize,
metrics: Arc<dyn Metrics>,
}Expand description
A peer sends and receives messages over a connection with a remote.
Peers are initialised with a Connection, which can be replaced
later, should it be necessary.
Messages sent are expected to be acknowledged, i.e. the remote needs to send back an ACK frame. Otherwise the message is resent after some time.
Fields§
§conf: Arc<Config>Network configuration.
budget: BudgetA budget limits how many message a peer can deliver to the application.
msgs: Queue<(RetryPolicy, Bytes)>Messages the application wants to be sent to the remote.
retry: DelayQueueMessages waiting to be retried if no ACK has been received.
tx: UnboundedSender<(PublicKey, Bytes, Option<OwnedSemaphorePermit>)>The channel over which to deliver inbound messages to the application.
countdown: CountdownA healthcheck countdown.
When dropped to 0 the connection should be replaced.
max_message_size: usizeThe true max. message size.
It accounts for the additional Trailer bytes.
metrics: Arc<dyn Metrics>Implementations§
Source§impl Peer
impl Peer
Sourcepub async fn start(
&mut self,
conn: Connection,
cancel: CancellationToken,
) -> Result<Empty, NetworkError>
pub async fn start( &mut self, conn: Connection, cancel: CancellationToken, ) -> Result<Empty, NetworkError>
Start I/O with a connected peer.
This method continues until an error occurs, after which callers may
want to reconnect and resume peer operation with a new Connection.