示例#1
0
        protected async Task <IConnection> CreateConnectionAsync(CancellationToken cancellationToken)
        {
            var connection = await _connectionFactory.CreateAndConnectAsync(EndPoint, cancellationToken)
                             .ConfigureAwait(false);

            try
            {
                await _connectionInitializer.InitializeConnectionAsync(connection, cancellationToken)
                .ConfigureAwait(false);

                if (BucketName != null)
                {
                    await _connectionInitializer.SelectBucketAsync(connection, BucketName, cancellationToken)
                    .ConfigureAwait(false);
                }

                return(connection);
            }
            catch
            {
                // Be sure to cleanup the connection if bootstrap fails.
                // Use the synchronous dispose as we don't need to wait for in-flight operations to complete.
                connection.Dispose();
                throw;
            }
        }
        protected async Task <IConnection> CreateConnectionAsync(CancellationToken cancellationToken)
        {
            var connection = await _connectionFactory.CreateAndConnectAsync(EndPoint, cancellationToken)
                             .ConfigureAwait(false);

            await _connectionInitializer.InitializeConnectionAsync(connection, cancellationToken).ConfigureAwait(false);

            if (BucketName != null)
            {
                await _connectionInitializer.SelectBucketAsync(connection, BucketName, cancellationToken).ConfigureAwait(false);
            }

            return(connection);
        }