/// <summary> /// Create a search service client from the specified base uri and credentials. /// </summary> /// <param name="baseUri">The URL to the root of the service</param> /// <param name="resourceType">Resource type to query against</param> /// <param name="credentials">The credentials to connect to the service with</param> /// <param name="healthIndicatorStore">Health indicator store</param> /// <param name="handlers">Handlers to apply to the request in order from first to last</param> public SearchClient(Uri baseUri, string resourceType, ICredentials credentials, IEndpointHealthIndicatorStore healthIndicatorStore, Action <Exception> onException, params DelegatingHandler[] handlers) { _resourceType = resourceType; // Link the handlers HttpMessageHandler handler = new HttpClientHandler() { Credentials = credentials, AllowAutoRedirect = true, UseDefaultCredentials = credentials == null }; foreach (var providedHandler in handlers.Reverse()) { providedHandler.InnerHandler = handler; handler = providedHandler; } _httpClient = new HttpClient(handler, disposeHandler: true); _retryingHttpClientWrapper = new RetryingHttpClientWrapper(_httpClient, healthIndicatorStore, onException); _discoveryClient = new ServiceDiscoveryClient(_httpClient, baseUri); }
/// <summary> /// Create a search service client from the specified base uri and credentials. /// </summary> /// <param name="baseUri">The URL to the root of the service</param> /// <param name="resourceType">Resource type to query against</param> /// <param name="credentials">The credentials to connect to the service with</param> /// <param name="healthIndicatorStore">Health indicator store</param> /// <param name="handlers">Handlers to apply to the request in order from first to last</param> public SearchClient(Uri baseUri, string resourceType, ICredentials credentials, IEndpointHealthIndicatorStore healthIndicatorStore, params DelegatingHandler[] handlers) { _resourceType = resourceType; // Link the handlers HttpMessageHandler handler = new HttpClientHandler() { Credentials = credentials, AllowAutoRedirect = true, UseDefaultCredentials = credentials == null }; foreach (var providedHandler in handlers.Reverse()) { providedHandler.InnerHandler = handler; handler = providedHandler; } var httpClient = new HttpClient(handler, disposeHandler: true); _retryingHttpClientWrapper = new RetryingHttpClientWrapper(httpClient, healthIndicatorStore); _discoveryClient = new ServiceDiscoveryClient(httpClient, baseUri); }
public AutocompleteServicePackageVersionsQuery(IAppConfiguration configuration) { _serviceDiscoveryClient = new ServiceDiscoveryClient(configuration.ServiceDiscoveryUri); _autocompleteServiceResourceType = configuration.AutocompleteServiceResourceType; _httpClient = new RetryingHttpClientWrapper(new HttpClient()); }