[FA-misc] Translation engine work
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using DeepL;
|
||||
using Polly;
|
||||
using Polly.Retry;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Services.Resilience;
|
||||
|
||||
public static class TranslationResiliencePipeline
|
||||
{
|
||||
public static ResiliencePipeline Build()
|
||||
{
|
||||
return new ResiliencePipelineBuilder()
|
||||
.AddRetry(new RetryStrategyOptions
|
||||
{
|
||||
ShouldHandle = new PredicateBuilder()
|
||||
.Handle<HttpRequestException>()
|
||||
.Handle<TaskCanceledException>(ex => ex.InnerException is TimeoutException)
|
||||
.Handle<ConnectionException>()
|
||||
.Handle<TooManyRequestsException>(),
|
||||
MaxRetryAttempts = 3,
|
||||
BackoffType = DelayBackoffType.Exponential,
|
||||
Delay = TimeSpan.FromMilliseconds(500),
|
||||
UseJitter = true
|
||||
})
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user