async fn send_periodic_heartbeats_with_shutdown_handle(
connected_addr: ConnectedAddr,
shutdown_rx: Receiver<CancelHeartbeatTask>,
server_tx: Sender<ClientRequest>,
heartbeat_ts_collector: Sender<MetaAddrChange>,
) -> Result<(), BoxError>
Expand description
Send periodical heartbeats to server_tx
, and update the peer status through
heartbeat_ts_collector
.
§Correctness
To prevent hangs:
- every await that depends on the network must have a timeout (or interval)
- every error/shutdown must update the address book state and return
The address book state can be updated via ClientRequest.tx
, or the
heartbeat_ts_collector.
Returning from this function terminates the connection’s heartbeat task.