public static IConnectionFactory CreateConnectionFactory(string clusterName) { if (DefaultSettings.Value == null) throw new ConfigurationErrorsException("No rethinkdb client configuration section located"); foreach (ClusterElement cluster in DefaultSettings.Value.Clusters) { if (cluster.Name == clusterName) { IConnectionFactory connectionFactory = CreateDefaultConnectionFactory(cluster); if (cluster.NetworkErrorHandling != null && cluster.NetworkErrorHandling.Enabled) connectionFactory = new ReliableConnectionFactory(connectionFactory); if (cluster.ConnectionPool != null && cluster.ConnectionPool.Enabled) connectionFactory = new ConnectionPoolingConnectionFactory(connectionFactory); else if (cluster.ConnectionPool != null && cluster.ConnectionPool.Enabled && cluster.ConnectionPool.QueryTimeout != 0) connectionFactory = new ConnectionPoolingConnectionFactory(connectionFactory, new TimeSpan(0, 0, cluster.ConnectionPool.QueryTimeout)); return connectionFactory; } } throw new ArgumentException("Cluster name could not be found in configuration", "clusterName"); }
public static IConnectionFactory CreateConnectionFactory(string clusterName) { if (DefaultSettings.Value == null) { throw new ConfigurationErrorsException("No rethinkdb client configuration section located"); } foreach (ClusterElement cluster in DefaultSettings.Value.Clusters) { if (cluster.Name == clusterName) { IConnectionFactory connectionFactory = CreateDefaultConnectionFactory(cluster); if (cluster.NetworkErrorHandling != null && cluster.NetworkErrorHandling.Enabled) { connectionFactory = new ReliableConnectionFactory(connectionFactory); } if (cluster.ConnectionPool != null && cluster.ConnectionPool.Enabled) { connectionFactory = new ConnectionPoolingConnectionFactory(connectionFactory); } return(connectionFactory); } } throw new ArgumentException("Cluster name could not be found in configuration", "clusterName"); }
public void SecondConnectionEstablishedIfFirstInUse() { var cf = new ConnectionPoolingConnectionFactory(rootConnectionFactory); var conn1 = cf.Get(); var conn2 = cf.Get(); AssertRealConnection1(conn1); AssertRealConnection2(conn2); conn1.Dispose(); conn2.Dispose(); }
public void RetrieveSameConnectionOverAndOver() { var cf = new ConnectionPoolingConnectionFactory(rootConnectionFactory); var conn1 = cf.Get(); AssertRealConnection1(conn1); conn1.Dispose(); conn1 = cf.Get(); AssertRealConnection1(conn1); conn1.Dispose(); conn1 = cf.Get(); AssertRealConnection1(conn1); conn1.Dispose(); conn1 = cf.Get(); AssertRealConnection1(conn1); conn1.Dispose(); }