public Cluster(string connectionString, ClusterOptions clusterOptions)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new InvalidConfigurationException("The connectionString cannot be null, empty or only be whitesapce.");
            }
            if (clusterOptions == null)
            {
                throw new InvalidConfigurationException("ClusterOptions is null.");
            }
            if (string.IsNullOrWhiteSpace(clusterOptions.Password) || string.IsNullOrWhiteSpace(clusterOptions.UserName))
            {
                throw new InvalidConfigurationException("Username and password are required.");
            }

            clusterOptions.WithConnectionString(connectionString);

            var configTokenSource = new CancellationTokenSource();

            _context = new ClusterContext(configTokenSource, clusterOptions);
            _context.StartConfigListening();

            _lazyQueryClient     = new Lazy <IQueryClient>(() => new QueryClient(_context));
            _lazyAnalyticsClient = new Lazy <IAnalyticsClient>(() => new AnalyticsClient(_context));
            _lazySearchClient    = new Lazy <ISearchClient>(() => new SearchClient(_context));
            _lazyQueryManager    = new Lazy <IQueryIndexManager>(() => new QueryIndexManager(_lazyQueryClient.Value));
            _lazyBucketManager   = new Lazy <IBucketManager>(() => new BucketManager(_context));
            _lazyUserManager     = new Lazy <IUserManager>(() => new UserManager(_context));
            _lazySearchManager   = new Lazy <ISearchIndexManager>(() => new SearchIndexManager(_context));
        }
Beispiel #2
0
        internal Cluster(ClusterOptions clusterOptions)
        {
            if (clusterOptions == null)
            {
                throw new InvalidConfigurationException("ClusterOptions is null.");
            }
            if (string.IsNullOrWhiteSpace(clusterOptions.Password) || string.IsNullOrWhiteSpace(clusterOptions.UserName))
            {
                throw new InvalidConfigurationException("Username and password are required.");
            }

            var configTokenSource = new CancellationTokenSource();

            _context = new ClusterContext(this, configTokenSource, clusterOptions);
            _context.StartConfigListening();

            LazyQueryClient           = new Lazy <IQueryClient>(() => _context.ServiceProvider.GetRequiredService <IQueryClient>());
            LazyAnalyticsClient       = new Lazy <IAnalyticsClient>(() => _context.ServiceProvider.GetRequiredService <IAnalyticsClient>());
            LazySearchClient          = new Lazy <ISearchClient>(() => _context.ServiceProvider.GetRequiredService <ISearchClient>());
            LazyQueryManager          = new Lazy <IQueryIndexManager>(() => _context.ServiceProvider.GetRequiredService <IQueryIndexManager>());
            LazyBucketManager         = new Lazy <IBucketManager>(() => _context.ServiceProvider.GetRequiredService <IBucketManager>());
            LazyUserManager           = new Lazy <IUserManager>(() => _context.ServiceProvider.GetRequiredService <IUserManager>());
            LazySearchManager         = new Lazy <ISearchIndexManager>(() => _context.ServiceProvider.GetRequiredService <ISearchIndexManager>());
            LazyAnalyticsIndexManager = new Lazy <IAnalyticsIndexManager>(() => _context.ServiceProvider.GetRequiredService <IAnalyticsIndexManager>());

            _logger            = _context.ServiceProvider.GetRequiredService <ILogger <Cluster> >();
            _retryOrchestrator = _context.ServiceProvider.GetRequiredService <IRetryOrchestrator>();
            _redactor          = _context.ServiceProvider.GetRequiredService <IRedactor>();

            var bootstrapperFactory = _context.ServiceProvider.GetRequiredService <IBootstrapperFactory>();

            _bootstrapper = bootstrapperFactory.Create(clusterOptions.BootstrapPollInterval);
        }
Beispiel #3
0
        internal Cluster(string connectionString, ClusterOptions?clusterOptions = null)
        {
            clusterOptions ??= new ClusterOptions();
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new InvalidConfigurationException("The connectionString cannot be null, empty or only be whitespace.");
            }
            if (clusterOptions == null)
            {
                throw new InvalidConfigurationException("ClusterOptions is null.");
            }
            if (string.IsNullOrWhiteSpace(clusterOptions.Password) || string.IsNullOrWhiteSpace(clusterOptions.UserName))
            {
                throw new InvalidConfigurationException("Username and password are required.");
            }

            clusterOptions.ConnectionString(connectionString);

            var configTokenSource = new CancellationTokenSource();

            _context = new ClusterContext(configTokenSource, clusterOptions);
            _context.StartConfigListening();

            LazyQueryClient     = new Lazy <IQueryClient>(() => _context.ServiceProvider.GetRequiredService <IQueryClient>());
            LazyAnalyticsClient = new Lazy <IAnalyticsClient>(() => _context.ServiceProvider.GetRequiredService <IAnalyticsClient>());
            LazySearchClient    = new Lazy <ISearchClient>(() => _context.ServiceProvider.GetRequiredService <ISearchClient>());
            LazyQueryManager    = new Lazy <IQueryIndexManager>(() => _context.ServiceProvider.GetRequiredService <IQueryIndexManager>());
            LazyBucketManager   = new Lazy <IBucketManager>(() => _context.ServiceProvider.GetRequiredService <IBucketManager>());
            LazyUserManager     = new Lazy <IUserManager>(() => _context.ServiceProvider.GetRequiredService <IUserManager>());
            LazySearchManager   = new Lazy <ISearchIndexManager>(() => _context.ServiceProvider.GetRequiredService <ISearchIndexManager>());

            _logger            = _context.ServiceProvider.GetRequiredService <ILogger <Cluster> >();
            _retryOrchestrator = _context.ServiceProvider.GetRequiredService <IRetryOrchestrator>();
        }