mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
add wait queue size stat to client connector
This commit is contained in:
parent
2a8c2fb55e
commit
bccd7c7671
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user