Skip to content

Commit 58a65d8

Browse files
committed
api calls retry
1 parent 4abb4ec commit 58a65d8

18 files changed

Lines changed: 31 additions & 39 deletions

MM.API/MM.API.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
</ItemGroup>
2323
<ItemGroup>
2424
<PackageReference Include="AWSSDK.Rekognition" Version="4.0.3.27" />
25-
<PackageReference Include="Azure.Storage.Blobs" Version="12.27.0" />
25+
<PackageReference Include="Azure.Storage.Blobs" Version="12.28.0" />
2626
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.15" />
2727
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.59.0" />
2828
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.2.0" />
2929
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
3030
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.7" />
3131
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.15" />
32+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.8" />
3233
<PackageReference Include="Sentry.AspNetCore" Version="6.5.0" />
3334
<PackageReference Include="Stripe.net" Version="51.2.0-beta.2" />
3435
</ItemGroup>

MM.API/Program.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.Hosting;
55
using Microsoft.Extensions.Logging;
6+
using Polly;
7+
using Polly.Extensions.Http;
68
using Stripe;
79

810
var app = new HostBuilder()
@@ -74,10 +76,11 @@ static void ConfigureServices(IServiceCollection services)
7476
{
7577
//http clients
7678

77-
services.AddHttpClient("paddle");
7879
services.AddHttpClient("apple");
79-
services.AddHttpClient("auth", client => { client.Timeout = TimeSpan.FromSeconds(60); });
80-
services.AddHttpClient("ipinfo");
80+
services.AddHttpClient("auth", client => { client.Timeout = TimeSpan.FromSeconds(30); });
81+
82+
services.AddHttpClient("ipinfo")
83+
.AddPolicyHandler(request => request.Method == HttpMethod.Get ? GetRetryPolicy() : Policy.NoOpAsync().AsAsyncPolicy<HttpResponseMessage>());
8184

8285
//repositories
8386

@@ -127,4 +130,12 @@ static void ConfigureServices(IServiceCollection services)
127130

128131
throw;
129132
}
130-
}
133+
}
134+
135+
//https://github.com/App-vNext/Polly/wiki/Polly-and-HttpClientFactory
136+
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
137+
{
138+
return HttpPolicyExtensions
139+
.HandleTransientHttpError() // 408,5xx
140+
.WaitAndRetryAsync([TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)]);
141+
}

MM.WEB/MM.WEB.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
<None Include="..\.editorconfig" Link=".editorconfig" />
2222
</ItemGroup>
2323
<ItemGroup>
24-
<PackageReference Include="BlazorWasmPreRendering.Build" Version="7.2.0" />
24+
<PackageReference Include="BlazorWasmPreRendering.Build" Version="8.0.0" />
2525
<PackageReference Include="Humanizer.Core" Version="3.0.10" />
2626
<PackageReference Include="Humanizer.Core.es" Version="3.0.10" />
2727
<PackageReference Include="Humanizer.Core.pt" Version="3.0.10" />
2828
<PackageReference Include="Bogus" Version="35.6.5" />
2929
<PackageReference Include="FluentValidation" Version="12.1.1" />
3030
<PackageReference Include="KristofferStrube.Blazor.MediaCaptureStreams" Version="0.4.1" />
31-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.7">
31+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.8">
3232
<TreatAsUsed>true</TreatAsUsed>
3333
</PackageReference>
34-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.7" PrivateAssets="all" />
35-
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="10.0.7">
34+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.8" PrivateAssets="all" />
35+
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="10.0.8">
3636
<TreatAsUsed>true</TreatAsUsed>
3737
</PackageReference>
38-
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.7" />
38+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.8" />
3939
<PackageReference Include="MudBlazor" Version="9.4.0" />
4040
<PackageReference Include="Sentry.AspNetCore.Blazor.WebAssembly" Version="6.5.0" />
4141
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.18.0" />

MM.WEB/Modules/Auth/AccountPopup.razor

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
@using MM.WEB.Core.Auth
2-
@using MM.WEB.Modules.Auth.Core
3-
@using MM.WEB.Modules.Profile.Core
1+
@using MM.WEB.Modules.Auth.Core
42
@using MM.WEB.Modules.Profile.Resources
53

64
@inherits ComponentCore<AccountPopup>

MM.WEB/Modules/Auth/LoginPage.razor

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
@page "/{culture}/login"
22

3-
@using MM.WEB.Core.Auth
43
@using MM.WEB.Modules.Auth.Resources
5-
@using MM.WEB.Modules.Subscription.Core
64
@using System.Text.RegularExpressions
75

86
@inherits PageCore<LoginPage>

MM.WEB/Modules/Auth/RegisterUser.razor

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
@page "/{culture}/register-user"
22
@inherits PageCore<RegisterUser>
33

4-
@using System.Security.Claims
5-
@using MM.WEB.Core.Auth
64
@using MM.WEB.Modules.Auth.Core
75
@using MM.WEB.Modules.Auth.Resources
86
@using MM.WEB.Modules.Subscription.Core

MM.WEB/Modules/Help/HelpCenter.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@page "/{culture}/help"
22
@inherits PageCore<HelpCenter>
33

4-
@using MM.WEB.Layout
54
@using MM.WEB.Modules.Auth.Core
65

76
@inject PrincipalApi PrincipalApi

MM.WEB/Modules/Index.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
@using MM.Shared.Models.Dashboard
44
@using Button = MM.WEB.Resources.Button
55
@using MM.WEB.Modules.Subscription.Core
6-
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
76
@inherits PageCore<Index>
87

98
@inject DashboardApi DashboardApi

MM.WEB/Modules/Profile/Components/CardCompatibility.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@using MM.Shared.Models.Profile
22
@using MM.WEB.Core.Enum
33
@using MM.WEB.Core.Models
4-
@using CardHeader = MM.WEB.Resources.CardHeader
54

65
<MudAlert Severity="@GetSeverity(null)" Icon="@GetIcon(null)" Variant="Variant.Filled" Dense="true" Class="@Css.Build().Medium("mb")">
76
<MudText Typo="Typo.h5" style="font-weight: bold;" Inline="false">

MM.WEB/Modules/Profile/Components/PopupProfile.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using MM.Shared.Models.Auth
2-
@using MM.Shared.Models.Profile
1+
@using MM.Shared.Models.Profile
32
@using MM.WEB.Core.Models
43
@using MM.WEB.Modules.Auth.Core
54
@using MM.WEB.Modules.Profile.Core

0 commit comments

Comments
 (0)