mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:46:30 +00:00
d842466594
put cryptography lib to fixed version fix race condition bug in queue handler add lock to db writing and backup to file db on each write
15 lines
686 B
C#
15 lines
686 B
C#
using Polly;
|
|
|
|
public static class ResilienceExt
|
|
{
|
|
public static void WithRetry(this Action operation, int retryCount = 3, int delayMs = 150) =>
|
|
Policy.Handle<Exception>()
|
|
.WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs),
|
|
(exception, timeSpan) => Console.WriteLine($"Exception: {exception}, TimeSpan: {timeSpan}"))
|
|
.Execute(operation);
|
|
|
|
public static TResult WithRetry<TResult>(this Func<TResult> operation, int retryCount = 3, int delayMs = 150) =>
|
|
Policy.Handle<Exception>()
|
|
.WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs))
|
|
.Execute(operation);
|
|
} |