1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 16:02:59 +01:00

add wait queue size stat to client connector

This commit is contained in:
Nikolay Kim 2018-07-17 01:57:57 +06:00
parent 2a8c2fb55e
commit bccd7c7671

View File

@ -34,6 +34,8 @@ use {HAS_OPENSSL, HAS_TLS};
pub struct ClientConnectorStats { pub struct ClientConnectorStats {
/// Number of waited-on connections /// Number of waited-on connections
pub waits: usize, pub waits: usize,
/// Size of the wait queue
pub wait_queue: usize,
/// Number of reused connections /// Number of reused connections
pub reused: usize, pub reused: usize,
/// Number of opened connections /// Number of opened connections
@ -494,8 +496,13 @@ impl ClientConnector {
ctx.run_later(Duration::from_secs(1), |act, ctx| act.collect_periodic(ctx)); ctx.run_later(Duration::from_secs(1), |act, ctx| act.collect_periodic(ctx));
// send stats // send stats
let stats = mem::replace(&mut self.stats, ClientConnectorStats::default()); let mut stats = mem::replace(&mut self.stats, ClientConnectorStats::default());
if let Some(ref mut subscr) = self.subscriber { if let Some(ref mut subscr) = self.subscriber {
if let Some(ref waiters) = self.waiters {
for w in waiters.values() {
stats.wait_queue += w.len();
}
}
let _ = subscr.do_send(stats); let _ = subscr.do_send(stats);
} }
} }