Skip to content

Instantly share code, notes, and snippets.

@bowrocker
Created December 12, 2019 00:14
Show Gist options
  • Save bowrocker/9986fddddb14a36fe9c188ab1bcdc512 to your computer and use it in GitHub Desktop.
Save bowrocker/9986fddddb14a36fe9c188ab1bcdc512 to your computer and use it in GitHub Desktop.
fn check_pool_connections<C>(
protected_data: ProtectedData<C>,
rebalance_check: RebalanceCheck,
log: Logger,
) where
C: Connection,
{
let mut connection_data = protected_data.connection_data_lock();
debug!(
log,
"Performing connection check on {} connections",
connection_data.connections.len()
);
connection_data.connections.retain(|pair| match pair {
ConnectionKeyPair((_key, Some(conn))) => conn.is_valid(),
ConnectionKeyPair((_key, None)) => {
warn!(log, "found malformed connection");
false
}
});
info!(log, "calling get_lock on rebalance check");
let mut rebalance = rebalance_check.get_lock();
if !*rebalance {
*rebalance = true;
info!(log, "calling condvar_nontify() on rebalance check");
rebalance_check.condvar_notify();
info!(log, "called condvar_notify() rebalance check");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment