コード例 #1
0
        private async Task CreateBucketAsync()
        {
            _logger.LogInformation("Attempting to create bucket...");
            var bucketManager  = _cluster.Buckets;
            var bucketSettings = new BucketSettings
            {
                BucketType = BucketType.Couchbase,
                Name       = _config.TargetBucket,
                RamQuotaMB = _config.TargetBucketRamQuotaMB
            };

            _logger.LogInformation($"Creating bucket `{_config.TargetBucket}`...");
            try
            {
                await bucketManager.CreateBucketAsync(bucketSettings);

                _logger.LogInformation("Bucket creation complete.");
            }
            catch (BucketExistsException)
            {
                _logger.LogInformation("already exists.");
            }

            _bucket = await _cluster.BucketAsync(_config.TargetBucket);

            var opts = new WaitUntilReadyOptions();

            opts.DesiredState(ClusterState.Online);
            opts.ServiceTypes(ServiceType.KeyValue, ServiceType.Query);
            await _bucket.WaitUntilReadyAsync(TimeSpan.FromSeconds(30), opts);

            _collManager = _bucket.Collections;
        }
コード例 #2
0
        public void Can_Override_ServiceType_Defaults()
        {
            //arrange

            var options = new WaitUntilReadyOptions();

            //act

            options.ServiceTypes(ServiceType.KeyValue, ServiceType.Query);

            //assert

            Assert.Equal(2, options.ServiceTypesValue.Count);
            Assert.Contains(options.ServiceTypesValue, type => type == ServiceType.KeyValue);
            Assert.Contains(options.ServiceTypesValue, type => type == ServiceType.Query);
        }