Exemple #1
0
        private void ConfigureInline(string name, System.Collections.Specialized.NameValueCollection config, ICouchbaseWebProvider provider)
        {
            var servers           = ProviderHelper.GetAndRemoveAsArray(config, "servers", ';', false).Select(x => new Uri(x)).ToList();
            var useSsl            = ProviderHelper.GetAndRemoveAsBool(config, "useSsl", false);
            var operationLifespan = ProviderHelper.GetAndRemoveAsUInt(config, "operationLifespan", false);
            var sendTimeout       = ProviderHelper.GetAndRemoveAsInt(config, "sendTimeout", false);
            var connectTimeout    = ProviderHelper.GetAndRemoveAsInt(config, "connectTimeout", false);
            var minPoolSize       = ProviderHelper.GetAndRemoveAsInt(config, "minPoolSize", false);
            var maxPoolSize       = ProviderHelper.GetAndRemoveAsInt(config, "maxPoolSize", false);
            var username          = ProviderHelper.GetAndRemove(config, "username", false);
            var password          = ProviderHelper.GetAndRemove(config, "password", false);

            var clientConfig = new ClientConfiguration
            {
                DefaultOperationLifespan = operationLifespan ?? ClientConfiguration.Defaults.DefaultOperationLifespan,
                UseSsl  = useSsl ?? ClientConfiguration.Defaults.UseSsl,
                Servers = servers.Any() ? servers : new List <Uri> {
                    new Uri("http://localhost:8091")
                },
                BucketConfigs = new Dictionary <string, BucketConfiguration>
                {
                    {
                        provider.BucketName, new BucketConfiguration
                        {
                            BucketName        = provider.BucketName,
                            PoolConfiguration = new PoolConfiguration
                            {
                                MinSize        = minPoolSize ?? PoolConfiguration.Defaults.MinSize,
                                MaxSize        = maxPoolSize ?? PoolConfiguration.Defaults.MaxSize,
                                SendTimeout    = sendTimeout ?? PoolConfiguration.Defaults.SendTimeout,
                                ConnectTimeout = connectTimeout ?? PoolConfiguration.Defaults.ConnectTimeout
                            }
                        }
                    }
                }
            };

            IAuthenticator authenticator = null;

            if (string.IsNullOrWhiteSpace(username))
            {
                if (!string.IsNullOrWhiteSpace(password))
                {
                    //assume pre-RBAC or CB < 5.0 if username is empty
                    authenticator = new ClassicAuthenticator(provider.BucketName, password);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(password))
                {
                    authenticator = new PasswordAuthenticator(username, password);
                }
            }

            MultiCluster.Configure(clientConfig, name, authenticator);

            _log.Debug("Creating bucket: " + provider.BucketName);
            provider.Bucket = MultiCluster.GetBucket(name, provider.BucketName);
        }
Exemple #2
0
        private void ConfigureFromSection(string name, System.Collections.Specialized.NameValueCollection config, ICouchbaseWebProvider provider)
        {
            //configure from the CouchbaseClientSection in Web.Config
            MultiCluster.Configure(name, config);

            _log.Debug("Creating bucket: " + provider.BucketName);
            provider.Bucket = MultiCluster.GetBucket(name, provider.BucketName);
        }
Exemple #3
0
 private void ConfigureManually(string name, System.Collections.Specialized.NameValueCollection config, ICouchbaseWebProvider provider)
 {
     _log.Debug("Creating bucket: " + provider.BucketName);
     provider.Bucket = MultiCluster.GetBucket(name, provider.BucketName);
 }