add polly for grpc calls
This commit is contained in:
parent
adb061cc27
commit
bcb0455d1a
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using System;
|
using System;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using Polly;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
||||||
{
|
{
|
||||||
@ -27,7 +28,11 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return await func(httpClient);
|
return await Policy
|
||||||
|
.Handle<Exception>(ex => true)
|
||||||
|
.WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress,e.Message))
|
||||||
|
.ExecuteAsync(() => func(httpClient))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
catch (RpcException e)
|
catch (RpcException e)
|
||||||
{
|
{
|
||||||
@ -59,7 +64,11 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await func(httpClient);
|
await Policy
|
||||||
|
.Handle<Exception>(ex => true)
|
||||||
|
.WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress, e.Message))
|
||||||
|
.ExecuteAsync(() => func(httpClient))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
catch (RpcException e)
|
catch (RpcException e)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using System;
|
using System;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using Polly;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
||||||
{
|
{
|
||||||
@ -27,7 +28,11 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return await func(httpClient);
|
return await Policy
|
||||||
|
.Handle<Exception>(ex => true)
|
||||||
|
.WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress, e.Message))
|
||||||
|
.ExecuteAsync(() => func(httpClient))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
catch (RpcException e)
|
catch (RpcException e)
|
||||||
{
|
{
|
||||||
@ -59,7 +64,11 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await func(httpClient);
|
await Policy
|
||||||
|
.Handle<Exception>(ex => true)
|
||||||
|
.WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => Log.Warning("Retrying the call to urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress}, errorMessage={@message}", urlGrpc, httpClient.BaseAddress, e.Message))
|
||||||
|
.ExecuteAsync(() => func(httpClient))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
catch (RpcException e)
|
catch (RpcException e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user