Reduce traffic on the stats channel (#69)

This commit is contained in:
Lev Kokotov
2022-05-17 13:05:25 -07:00
committed by GitHub
parent 54699222f8
commit fe32b5ef17

View File

@@ -209,23 +209,22 @@ impl ConnectionPool {
let index = self.round_robin % addresses.len(); let index = self.round_robin % addresses.len();
let address = &addresses[index]; let address = &addresses[index];
self.stats.client_waiting(process_id, address.id);
// Make sure you're getting a primary or a replica // Make sure you're getting a primary or a replica
// as per request. If no specific role is requested, the first // as per request. If no specific role is requested, the first
// available will be chosen. // available will be chosen.
if address.role != role { if address.role != role {
self.stats.client_disconnecting(process_id, address.id);
continue; continue;
} }
allowed_attempts -= 1; allowed_attempts -= 1;
if self.is_banned(address, shard, role) { if self.is_banned(address, shard, role) {
self.stats.client_disconnecting(process_id, address.id);
continue; continue;
} }
// Indicate we're waiting on a server connection from a pool.
self.stats.client_waiting(process_id, address.id);
// Check if we can connect // Check if we can connect
let mut conn = match self.databases[shard][index].get().await { let mut conn = match self.databases[shard][index].get().await {
Ok(conn) => conn, Ok(conn) => conn,