Exemple #1
0
        public void DefaultCreationBehaviorIsRetained()
        {
            var options = new ConsulClusteringOptions();

            // ensure we set a default value.
            var actual = options.CreateClient;

            Assert.NotNull(actual);
        }
        protected override IGatewayListProvider CreateGatewayListProvider(ILogger logger)
        {
            ConsulTestUtils.EnsureConsul();
            var options = new ConsulClusteringOptions();
            var address = new Uri(this.connectionString);

            options.ConfigureConsulClient(address);

            return(new ConsulGatewayListProvider(loggerFactory.CreateLogger <ConsulGatewayListProvider>(), Options.Create(options), this.gatewayOptions, this.clusterOptions));
        }
        protected override IMembershipTable CreateMembershipTable(ILogger logger)
        {
            ConsulTestUtils.EnsureConsul();
            var options = new ConsulClusteringOptions();
            var address = new Uri(this.connectionString);

            options.ConfigureConsulClient(address);

            return(new ConsulBasedMembershipTable(loggerFactory.CreateLogger <ConsulBasedMembershipTable>(), Options.Create(options), this.clusterOptions));
        }
Exemple #4
0
        public void ThrowsArgumentNullExceptionIfCallbackIsNull()
        {
            var options = new ConsulClusteringOptions();
            Func <IConsulClient> callback = null;

            // ensure we check the callback.
            var shouldThrow = () => options.ConfigureConsulClient(callback);

            Assert.Throws <ArgumentNullException>(shouldThrow);
        }
Exemple #5
0
 public ConsulGatewayListProvider(
     ILogger <ConsulGatewayListProvider> logger,
     IOptions <ConsulClusteringOptions> options,
     IOptions <GatewayOptions> gatewayOptions,
     IOptions <ClusterOptions> clusterOptions)
 {
     this.logger       = logger;
     this.clusterId    = clusterOptions.Value.ClusterId;
     this.maxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
     this.options      = options.Value;
     this.kvRootFolder = options.Value.KvRootFolder;
 }
Exemple #6
0
 public ConsulBasedMembershipTable(
     ILogger <ConsulBasedMembershipTable> logger,
     IOptions <ConsulClusteringOptions> membershipTableOptions,
     IOptions <ClusterOptions> clusterOptions)
 {
     this.clusterId    = clusterOptions.Value.ClusterId;
     this.kvRootFolder = membershipTableOptions.Value.KvRootFolder;
     this._logger      = logger;
     this.clusteringSiloTableOptions = membershipTableOptions.Value;
     this._consulClient = this.clusteringSiloTableOptions.CreateClient();
     versionKey         = ConsulSiloRegistrationAssembler.FormatVersionKey(clusterId, kvRootFolder);
 }
Exemple #7
0
        public void WeCanUseConfigureToSetupTheDefaultClientWithoutAAclToken()
        {
            var address = new Uri("http://localhost:8501");
            var options = new ConsulClusteringOptions();

            //we can configure the default consult client
            options.ConfigureConsulClient(address);

            var client = (ConsulClient)options.CreateClient();

            Assert.Equal(address, client.Config.Address);
            Assert.Null(client.Config.Token);
        }
Exemple #8
0
        public void WeCanInjectAConsulClient()
        {
            var fakeConsul = new FakeConsul();
            var options    = new ConsulClusteringOptions();
            Func <IConsulClient> callback = () => fakeConsul;

            //we can inject the consul
            options.ConfigureConsulClient(callback);

            var actual = options.CreateClient();

            Assert.Equal(fakeConsul, actual);
        }