/// <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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
 /// <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;
 }
예제 #10
0
 public AsmxFunnyQuotesClient(IDiscoveryClient discoveryClient, IOptionsSnapshot <FunnyQuotesConfiguration> config)
 {
     _config = config;
     _dicoveryAddressResolver = new DiscoveryHttpClientHandlerBase(discoveryClient);
 }