Skip to content

Commit

Permalink
playing with resilience
Browse files Browse the repository at this point in the history
  • Loading branch information
f2calv committed Sep 30, 2024
1 parent 81fd701 commit 63bc25b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/CasCap.Apis.GooglePhotos/Extensions/DI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Polly;
using System.Net;
using System.Net;
using System.Net.Http.Headers;

namespace Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -59,10 +58,26 @@ static void AddServices(this IServiceCollection services,
.SetHandlerLifetime(Timeout.InfiniteTimeSpan)
.AddStandardResilienceHandler((options) =>
{
//RateLimiter
options.TotalRequestTimeout = new Http.Resilience.HttpTimeoutStrategyOptions
{
Timeout = TimeSpan.FromSeconds(90)
};
//Retry
options.Retry = new Http.Resilience.HttpRetryStrategyOptions
{
MaxRetryAttempts = 6
};
//Circuit Breaker
options.CircuitBreaker = new Http.Resilience.HttpCircuitBreakerStrategyOptions
{
SamplingDuration = TimeSpan.FromSeconds(180)
};
//AttemptTimeout
options.AttemptTimeout = new Http.Resilience.HttpTimeoutStrategyOptions
{
Timeout = TimeSpan.FromSeconds(90)
};
});
}
}

0 comments on commit 63bc25b

Please sign in to comment.