solana_connection_cache/
client_connection.rs

1use {
2    solana_metrics::MovingStat,
3    solana_transaction_error::TransportResult,
4    std::{net::SocketAddr, sync::atomic::AtomicU64},
5};
6
7#[derive(Default)]
8pub struct ClientStats {
9    pub total_connections: AtomicU64,
10    pub connection_reuse: AtomicU64,
11    pub connection_errors: AtomicU64,
12    pub zero_rtt_accepts: AtomicU64,
13    pub zero_rtt_rejects: AtomicU64,
14
15    // these will be the last values of these stats
16    pub congestion_events: MovingStat,
17    pub streams_blocked_uni: MovingStat,
18    pub data_blocked: MovingStat,
19    pub acks: MovingStat,
20    pub make_connection_ms: AtomicU64,
21    pub send_timeout: AtomicU64,
22    /// The time spent sending packets when packets are successfully sent. This include both time
23    /// preparing for a connection (either obtaining from cache or create a new one in case of cache miss
24    /// or connection error)
25    pub send_packets_us: AtomicU64,
26    /// `prepare_connection_us` differs from `make_connection_ms` in that it accounts for the time spent
27    /// on obtaining a successful connection including time spent on retries when sending a packet.
28    pub prepare_connection_us: AtomicU64,
29    /// Count of packets successfully sent
30    pub successful_packets: AtomicU64,
31}
32
33pub trait ClientConnection: Sync + Send {
34    fn server_addr(&self) -> &SocketAddr;
35
36    fn send_data(&self, buffer: &[u8]) -> TransportResult<()>;
37
38    fn send_data_async(&self, buffer: Vec<u8>) -> TransportResult<()>;
39
40    fn send_data_batch(&self, buffers: &[Vec<u8>]) -> TransportResult<()>;
41
42    fn send_data_batch_async(&self, buffers: Vec<Vec<u8>>) -> TransportResult<()>;
43}