瀏覽代碼

Added BulkedPolicy.

tags/v1.1.0^2
Nemanja Grkovic 3 年之前
父節點
當前提交
82f309a0e8

+ 1
- 0
GrpcShared/Interfaces/ITrackService.cs 查看文件

@@ -18,5 +18,6 @@ namespace GrpcShared.Interfaces
Task<SingleTrackResponse> ListSingleTrackAsync(SingleTrackRequest request);
Task<MultipleTrackResponse> ListMultipleTrackAsync(MultipleTrackRequest request);
Task SaveTracks(SaveTracksRequest request);
Task<Microsoft.AspNetCore.Components.Authorization.AuthenticationState> GetAuthenticationStateAsync();
}
}

+ 0
- 1
IdentityProvider/IdentityProvider.csproj 查看文件

@@ -19,7 +19,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\gRPCServer\SpotifyService.csproj" />
<ProjectReference Include="..\GrpcShared\GrpcShared.csproj" />
<ProjectReference Include="..\NemAnCore\NemAnBlazor.csproj" />
</ItemGroup>

+ 1
- 1
NemAnCore/Shared/MainLayout.razor 查看文件

@@ -1,7 +1,7 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<div style="background: green ;" class="sidebar">
<NavMenu />
</div>


+ 9
- 1
gRPCServer/Program.cs 查看文件

@@ -30,7 +30,15 @@ builder.Services.AddHttpClient("HttpClient", c =>
})
.SetHandlerLifetime(TimeSpan.FromMinutes(5))
.AddPolicyHandler(GetRetryPolicy())
.AddPolicyHandler(GetCircuitBreaker());
.AddPolicyHandler(GetCircuitBreaker())
.AddPolicyHandler(GetBulkheadPolicy(50,200));

IAsyncPolicy<HttpResponseMessage> GetBulkheadPolicy(int capacity, int queueLength)
{
//As soon as we hit 50 concurrent requests, the policy will add subsequent requests to the pending request queue.
//Once the pending request queue is full, then the policy will start rejecting any other calls to the service.
return Policy.BulkheadAsync<HttpResponseMessage>(capacity, queueLength);
}

IAsyncPolicy<HttpResponseMessage> GetCircuitBreaker()
{

+ 1
- 0
gRPCServer/SpotifyService.csproj 查看文件

@@ -22,6 +22,7 @@

<ItemGroup>
<ProjectReference Include="..\GrpcShared\GrpcShared.csproj" />
<ProjectReference Include="..\IdentityProvider\IdentityProvider.csproj" />
<ProjectReference Include="..\NemAnCore\NemAnBlazor.csproj" />
</ItemGroup>


Loading…
取消
儲存