public async Task Initialize(IConfiguration config)
        {
            if (string.IsNullOrWhiteSpace(config.Password) || string.IsNullOrWhiteSpace(config.UserName))
            {
                throw new ArgumentNullException(nameof(config), "Username and password are required.");
            }

            _configuration = config;
            if (!_configuration.Buckets.Any())
            {
                _configuration = _configuration.WithBucket("default");
                _configuration = _configuration.WithServers("couchbase://localhost");
            }

            foreach (var configBucket in _configuration.Buckets)
            {
                foreach (var configServer in _configuration.Servers)
                {
                    var bucket = new CouchbaseBucket(this, configBucket);
                    await bucket.BootstrapAsync(configServer, _configuration).ConfigureAwait(false);

                    _bucketRefs.TryAdd(configBucket, bucket);
                    return;
                }
            }
        }
        private void Connect()
        {
            if (!_configuration.Buckets.Any())
            {
                _configuration = _configuration.WithBucket("default");
            }

            if (!_configuration.Servers.Any())
            {
                _configuration = _configuration.WithServers("couchbase://localhost");
            }

            Task.Run(async() =>
            {
                foreach (var configBucket in _configuration.Buckets)
                {
                    Log.LogDebug("Creating bucket {0}", configBucket);

                    foreach (var configServer in _configuration.Servers)
                    {
                        Log.LogDebug("Bootstrapping bucket {0} using server {1}", configBucket, configServer);

                        var bucket = new CouchbaseBucket(this, configBucket);
                        await bucket.BootstrapAsync(configServer, _configuration).ConfigureAwait(false);
                        _bucketRefs.TryAdd(configBucket, bucket);

                        Log.LogDebug("Succesfully bootstrapped bucket {0} using server {1}", configBucket,
                                     configServer);
                        return;
                    }
                }
            })
            .ConfigureAwait(false)
            .GetAwaiter()
            .GetResult();
        }