/// <summary> /// Initializes a new instance of the <see cref="DiscoveryHttpMessageHandler"/> class. /// </summary> /// <param name="discoveryClient">Service discovery client to use - provided by calling services.AddDiscoveryClient(Configuration)</param> /// <param name="logger">ILogger for capturing logs from Discovery operations</param> public DiscoveryHttpMessageHandler(IDiscoveryClient discoveryClient, ILogger <DiscoveryHttpClientHandler> logger = null) { if (discoveryClient == null) { throw new ArgumentNullException(nameof(discoveryClient)); } discoveryBase = new DiscoveryHttpClientHandlerBase(discoveryClient, logger); }
public async Task LookupServiceAsync_FindsService_ReturnsURI() { IDiscoveryClient client = new TestDiscoveryClient(new TestServiceInstance(new Uri("https://foundit:5555"))); var handler = new DiscoveryHttpClientHandlerBase(client); var uri = new Uri("https://foo/test/bar/foo?test=1&test2=2"); var result = await handler.LookupServiceAsync(uri); Assert.Equal(new Uri("https://foundit:5555/test/bar/foo?test=1&test2=2"), result); }
public async Task LookupServiceAsync_DoesntFindService_ReturnsOriginalURI() { IDiscoveryClient client = new TestDiscoveryClient(); var handler = new DiscoveryHttpClientHandlerBase(client); var uri = new Uri("https://foo/test"); var result = await handler.LookupServiceAsync(uri); Assert.Equal(uri, result); }
public void LookupService_NonDefaultPort_ReturnsOriginalURI() { IDiscoveryClient client = new TestDiscoveryClient(); var handler = new DiscoveryHttpClientHandlerBase(client); var uri = new Uri("https://foo:8080/test"); var result = handler.LookupService(uri); Assert.Equal(uri, result); }
public async Task LookupServiceAsync_NonDefaultPort_ReturnsOriginalURI() { // Arrange IDiscoveryClient client = new TestDiscoveryClient(); var handler = new DiscoveryHttpClientHandlerBase(client); var uri = new Uri("https://foo:8080/test"); // Act and Assert var result = await handler.LookupServiceAsync(uri); Assert.Equal(uri, result); }
public void LookupService_FindsService_ReturnsURI() { // Arrange IDiscoveryClient client = new TestDiscoveryClient(new TestServiceInstance(new Uri("https://foundit:5555"))); var handler = new DiscoveryHttpClientHandlerBase(client); var uri = new Uri("https://foo/test/bar/foo?test=1&test2=2"); // Act and Assert var result = handler.LookupService(uri); Assert.Equal(new Uri("https://foundit:5555/test/bar/foo?test=1&test2=2"), result); }
public void LookupService_DoesntFindService_ReturnsOriginalURI() { // Arrange IDiscoveryClient client = new TestDiscoveryClient(); var handler = new DiscoveryHttpClientHandlerBase(client); var uri = new Uri("https://foo/test"); // Act and Assert var result = handler.LookupService(uri); Assert.Equal(uri, result); }
public WcfFunnyQuotesClient(IDiscoveryClient discoveryClient, IOptionsSnapshot <FunnyQuotesConfiguration> config) { var circuitBreaker = Policy .Handle <Exception>() .CircuitBreakerAsync(2, TimeSpan.FromMinutes(15)); var retryOnFailure = Policy.Handle <Exception>().RetryAsync(1); var timeout = Policy.TimeoutAsync(TimeSpan.FromSeconds(2)); _apiCallPolicy = Policy.WrapAsync(circuitBreaker, timeout, retryOnFailure); _config = config; _discoveryClient = new DiscoveryHttpClientHandlerBase(discoveryClient); }
/// <summary> /// Initializes a new instance of the <see cref="DiscoveryHttpMessageHandler"/> class. /// </summary> /// <param name="discoveryClient">Service discovery client to use - provided by calling services.AddDiscoveryClient(Configuration)</param> /// <param name="logger">ILogger for capturing logs from Discovery operations</param> public DiscoveryHttpMessageHandler(IDiscoveryClient discoveryClient, ILogger <DiscoveryHttpClientHandler> logger = null) { _discoveryBase = new DiscoveryHttpClientHandlerBase(discoveryClient, logger); _logger = logger; }
public AsmxFunnyQuotesClient(IDiscoveryClient discoveryClient, IOptionsSnapshot <FunnyQuotesConfiguration> config) { _config = config; _dicoveryAddressResolver = new DiscoveryHttpClientHandlerBase(discoveryClient); }