Exemplo n.º 1
0
        public void ReturnSamePoolForSameConnectionString()
        {
            var pool1 = ConnectionPool.GetPool(new ConnectionOptions("tarantool-host1,tarantool-host2,tarantool-host3"));
            var pool2 = ConnectionPool.GetPool(new ConnectionOptions("tarantool-host1,tarantool-host2,tarantool-host3"));

            Assert.Equal(pool1, pool2);
        }
Exemplo n.º 2
0
        public void ReturnNotSamePoolForDifferentConnectionString()
        {
            var pool1 = ConnectionPool.GetPool(new ConnectionOptions("tarantool-host1,tarantool-host2,tarantool-host3"));
            var pool2 = ConnectionPool.GetPool(new ConnectionOptions("tarantool-hostA,tarantool-hostB,tarantool-hostC"));

            Assert.NotEqual(pool1, pool2);
        }
Exemplo n.º 3
0
        public async Task CreateFirstConnection()
        {
            var pool =
                (ConnectionPool)
                ConnectionPool.GetPool(new ConnectionOptions("127.0.0.1:3301"));

            Assert.Equal(0, pool._connections().Count);

            using (var connection = await pool.AcquireConnectionAsync())
            {
                Assert.NotNull(connection);
                Assert.Equal(1, pool._connections().Count);
            }
            Assert.Equal(1, pool._connections().Count);
        }
        public async Task ReuseConnection()
        {
            var pool =
                (ConnectionPool)
                ConnectionPool.GetPool(new ConnectionOptions("tarantool-host:3303"));

            using (await pool.AcquireConnectionAsync())
            {
            }
            Assert.Equal(1, pool._connections().Count);

            using (var connection = await pool.AcquireConnectionAsync())
            {
                Assert.NotNull(connection);
                Assert.Equal(1, pool._connections().Count);
            }
            Assert.Equal(1, pool._connections().Count);
        }
        public async Task CreateNewConnectionWhenAcquired()
        {
            var pool =
                (ConnectionPool)
                ConnectionPool.GetPool(new ConnectionOptions("tarantool-host:3302"));

            using (await pool.AcquireConnectionAsync())
            {
                Assert.Equal(1, pool._connections().Count);

                using (var connection = await pool.AcquireConnectionAsync())
                {
                    Assert.NotNull(connection);
                    Assert.Equal(2, pool._connections().Count);
                }
            }
            Assert.Equal(2, pool._connections().Count);
        }
 private TarantoolClient(ConnectionOptions connectionOptions)
 {
     _connectionPool = ConnectionPool.GetPool(connectionOptions);
 }