Sinet.Universal.Admin/test/Sinet.Universal.Admin.HttpA.../AdminConsoleApiClientModule.cs

31 lines
940 B
C#
Raw Normal View History

2023-11-07 23:29:26 +08:00
using System;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using Volo.Abp.Autofac;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.IdentityModel;
using Volo.Abp.Modularity;
namespace Sinet.Universal.Admin.HttpApi.Client.ConsoleTestApp;
[DependsOn(
typeof(AbpAutofacModule),
typeof(AdminHttpApiClientModule),
typeof(AbpHttpClientIdentityModelModule)
)]
public class AdminConsoleApiClientModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<AbpHttpClientBuilderOptions>(options =>
{
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
{
clientBuilder.AddTransientHttpErrorPolicy(
policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
);
});
});
}
}