1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-08-01 18:25:04 +00: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 {
/// Number of waited-on connections
pub waits: usize,
/// Size of the wait queue
pub wait_queue: usize,
/// Number of reused connections
pub reused: usize,
/// Number of opened connections
@ -494,8 +496,13 @@ impl ClientConnector {
ctx.run_later(Duration::from_secs(1), |act, ctx| act.collect_periodic(ctx));
// 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 waiters) = self.waiters {
for w in waiters.values() {
stats.wait_queue += w.len();
}
}
let _ = subscr.do_send(stats);
}
}