Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using Polly;
using Polly.CircuitBreaker;
public class CircuitBreakerHandler
private readonly IEmailService _emailService;
private readonly ILogger _logger;
private CircuitBreakerPolicy _circuitBreaker;
public CircuitBreakerHandler(IEmailService emailService, ILogger logger)
_emailService = emailService;
_logger = logger;
_circuitBreaker = Policy
exceptionsAllowedBeforeBreaking: 1,
durationOfBreak: TimeSpan.FromSeconds(1)
public void HandleNotification(Notification notification)
_circuitBreaker.Execute(() =>
catch (Exception e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment