modify rtr server metrics data
This commit is contained in:
@@ -2,7 +2,7 @@ use std::net::SocketAddr;
|
||||
use std::path::Path;
|
||||
use std::sync::{
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||
};
|
||||
|
||||
use tokio::sync::{Semaphore, broadcast, watch};
|
||||
@@ -26,6 +26,8 @@ pub struct RtrService {
|
||||
handshake_limiter: Arc<Semaphore>,
|
||||
active_connections: Arc<AtomicUsize>,
|
||||
transport_connections: Arc<RtrTransportConnectionCounters>,
|
||||
connection_change_tx: watch::Sender<u64>,
|
||||
connection_change_seq: Arc<AtomicU64>,
|
||||
config: RtrServiceConfig,
|
||||
}
|
||||
|
||||
@@ -33,6 +35,7 @@ pub struct RtrService {
|
||||
pub struct RtrServiceStats {
|
||||
active_connections: Arc<AtomicUsize>,
|
||||
transport_connections: Arc<RtrTransportConnectionCounters>,
|
||||
connection_change_tx: watch::Sender<u64>,
|
||||
max_connections: usize,
|
||||
}
|
||||
|
||||
@@ -48,6 +51,10 @@ impl RtrServiceStats {
|
||||
pub fn max_connections(&self) -> usize {
|
||||
self.max_connections
|
||||
}
|
||||
|
||||
pub fn subscribe_connection_changes(&self) -> watch::Receiver<u64> {
|
||||
self.connection_change_tx.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
impl RtrService {
|
||||
@@ -58,6 +65,7 @@ impl RtrService {
|
||||
pub fn with_config(cache: SharedRtrCache, config: RtrServiceConfig) -> Self {
|
||||
let (notify_tx, _) = broadcast::channel(config.notify_queue_size);
|
||||
let (shutdown_tx, _) = watch::channel(false);
|
||||
let (connection_change_tx, _) = watch::channel(0);
|
||||
|
||||
Self {
|
||||
cache,
|
||||
@@ -67,6 +75,8 @@ impl RtrService {
|
||||
handshake_limiter: Arc::new(Semaphore::new(config.max_concurrent_handshakes)),
|
||||
active_connections: Arc::new(AtomicUsize::new(0)),
|
||||
transport_connections: Arc::new(RtrTransportConnectionCounters::default()),
|
||||
connection_change_tx,
|
||||
connection_change_seq: Arc::new(AtomicU64::new(0)),
|
||||
config,
|
||||
}
|
||||
}
|
||||
@@ -99,6 +109,7 @@ impl RtrService {
|
||||
RtrServiceStats {
|
||||
active_connections: self.active_connections.clone(),
|
||||
transport_connections: self.transport_connections.clone(),
|
||||
connection_change_tx: self.connection_change_tx.clone(),
|
||||
max_connections: self.config.max_connections,
|
||||
}
|
||||
}
|
||||
@@ -113,6 +124,8 @@ impl RtrService {
|
||||
self.handshake_limiter.clone(),
|
||||
self.active_connections.clone(),
|
||||
self.transport_connections.clone(),
|
||||
self.connection_change_tx.clone(),
|
||||
self.connection_change_seq.clone(),
|
||||
self.config.clone(),
|
||||
)
|
||||
}
|
||||
@@ -127,6 +140,8 @@ impl RtrService {
|
||||
self.handshake_limiter.clone(),
|
||||
self.active_connections.clone(),
|
||||
self.transport_connections.clone(),
|
||||
self.connection_change_tx.clone(),
|
||||
self.connection_change_seq.clone(),
|
||||
self.config.clone(),
|
||||
)
|
||||
}
|
||||
@@ -141,6 +156,8 @@ impl RtrService {
|
||||
self.handshake_limiter.clone(),
|
||||
self.active_connections.clone(),
|
||||
self.transport_connections.clone(),
|
||||
self.connection_change_tx.clone(),
|
||||
self.connection_change_seq.clone(),
|
||||
self.config.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user