public void ServiceEndpointsCanBeACollection() { var source = new ConsulConfigurationSource() .UseCache(new InMemoryEmergencyCache()) .MapService("myservice1", "serviceEndpoints:v1:myservice", EndpointFormatters.AddressAndPort, NodeSelectors.All); var consulState = new ConsulState(); consulState = consulState.UpdateService(new Service { Name = "myservice1", Nodes = new[] { new ServiceNode { Address = "myaddress", Port = 80 }, new ServiceNode { Address = "anotheraddress", Port = 8080 } } }); var configProvider = _consul.LoadConfigProvider(source, consulState); string serviceEndpoint; configProvider.TryGet("serviceEndpoints:v1:myservice:0", out serviceEndpoint).Should().BeTrue(); serviceEndpoint.Should().Be("myaddress:80"); configProvider.TryGet("serviceEndpoints:v1:myservice:1", out serviceEndpoint).Should().BeTrue(); serviceEndpoint.Should().Be("anotheraddress:8080"); }
public static IConfigurationProvider LoadConfigProvider(this FakeObservableConsul consul, ConsulConfigurationSource configSource, ConsulState consulState = null) { var configProvider = (ConsulConfigurationProvider)configSource.Build(consul); if (consulState != null) { consul.CurrentState = consulState; } Task.WhenAll(configProvider.LoadAsync(), Task.Run(() => { consul.DependencyObservations.OnNext(consulState); })).GetAwaiter().GetResult(); return(configProvider); }
public ConfigurationLoadingSpec() { _configSource = new ConsulConfigurationSource() .UseCache(_cache) .MapKeyPrefix("apps/myapp", "consul"); }
public IntegrationTests() { _client = new ConsulClient(); _source = new ConsulConfigurationSource(() => new ConsulClient()); _prefix = Guid.NewGuid().ToString(); }