コード例 #1
0
        public static IPolicyRegistry <string> AddLCUPollyRegistry(this IServiceCollection services,
                                                                   LCUStartupHTTPClientOptions httpOpts)
        {
            var registry = services.AddPolicyRegistry();

            if (httpOpts != null)
            {
                var timeout = Policy.TimeoutAsync <HttpResponseMessage>(TimeSpan.FromSeconds(httpOpts.TimeoutSeconds));

                registry.Add("regular", timeout);

                var longTimeout = Policy.TimeoutAsync <HttpResponseMessage>(TimeSpan.FromSeconds(httpOpts.LongTimeoutSeconds));

                registry.Add("long", longTimeout);
            }

            return(registry);
        }
コード例 #2
0
        public static IHttpClientBuilder AddLCUHTTPClient <TClient>(this IServiceCollection services,
                                                                    IPolicyRegistry <string> registry, LCUStartupHTTPClientOptions httpOpts)
            where TClient : class
        {
            var clientName = typeof(TClient).Name;

            var clientOptions = httpOpts.Options[clientName];

            return(services.AddLCUHTTPClient <TClient>(registry, new Uri(clientOptions.BaseAddress)));
        }