internal void Update(IRoutingTable newTable) { var added = newTable.All(); added.ExceptWith(_routingTable.All()); var removed = _routingTable.All(); removed.ExceptWith(newTable.All()); _poolManager.UpdateConnectionPool(added, removed); _routingTable = newTable; _logger?.Info("Updated routingTable to be {0}", _routingTable); }
internal async Task UpdateAsync(IRoutingTable newTable) { var added = newTable.All(); added.ExceptWith(_routingTable.All()); var removed = _routingTable.All(); removed.ExceptWith(newTable.All()); await _poolManager.UpdateConnectionPoolAsync(added, removed).ConfigureAwait(false); _routingTable = newTable; _logger?.Info("Updated routingTable to be {0}", _routingTable); }
private static LoadBalancer SetupLoadBalancer(IRoutingTable routingTable) { var uris = routingTable.All(); // create a mocked cluster connection pool, which will return the same connection for each different uri var mockedClusterPool = new Mock <IClusterConnectionPool>(); foreach (var uri in uris) { var mockedConn = new Mock <IPooledConnection>(); mockedConn.Setup(x => x.Server.Address).Returns(uri.ToString); var conn = mockedConn.Object; mockedClusterPool.Setup(x => x.TryAcquire(uri, out conn)).Returns(true); } return(new LoadBalancer(mockedClusterPool.Object, routingTable)); }