solana_connection_cache/
client_connection.rs

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