<PackageReference Include="Polly" Version="8.5.2" />

AsyncCircuitBreakerSyntax

public static class AsyncCircuitBreakerSyntax
Fluent API for defining a Circuit Breaker AsyncPolicy.
public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak)

Builds a AsyncPolicy that will function like a Circuit Breaker.

The circuit will break if exceptionsAllowedBeforeBreaking exceptions that are handled by this policy are raised consecutively.

The circuit will stay broken for the durationOfBreak. Any attempt to execute this policy while the circuit is broken, will immediately throw a BrokenCircuitException containing the exception that broke the circuit.

If the first action after the break duration period results in a handled exception, the circuit will break again for another durationOfBreak; if no exception is thrown, the circuit will reset.

public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan> onBreak, Action onReset)

Builds a AsyncPolicy that will function like a Circuit Breaker.

The circuit will break if exceptionsAllowedBeforeBreaking exceptions that are handled by this policy are raised consecutively.

The circuit will stay broken for the durationOfBreak. Any attempt to execute this policy while the circuit is broken, will immediately throw a BrokenCircuitException containing the exception that broke the circuit.

If the first action after the break duration period results in a handled exception, the circuit will break again for another durationOfBreak; if no exception is thrown, the circuit will reset.

public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan, Context> onBreak, Action<Context> onReset)

Builds a AsyncPolicy that will function like a Circuit Breaker.

The circuit will break if exceptionsAllowedBeforeBreaking exceptions that are handled by this policy are raised consecutively.

The circuit will stay broken for the durationOfBreak. Any attempt to execute this policy while the circuit is broken, will immediately throw a BrokenCircuitException containing the exception that broke the circuit.

If the first action after the break duration period results in a handled exception, the circuit will break again for another durationOfBreak; if no exception is thrown, the circuit will reset.

public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan> onBreak, Action onReset, Action onHalfOpen)

Builds a AsyncPolicy that will function like a Circuit Breaker.

The circuit will break if exceptionsAllowedBeforeBreaking exceptions that are handled by this policy are raised consecutively.

The circuit will stay broken for the durationOfBreak. Any attempt to execute this policy while the circuit is broken, will immediately throw a BrokenCircuitException containing the exception that broke the circuit.

If the first action after the break duration period results in a handled exception, the circuit will break again for another durationOfBreak; if no exception is thrown, the circuit will reset.

public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan, Context> onBreak, Action<Context> onReset, Action onHalfOpen)

Builds a AsyncPolicy that will function like a Circuit Breaker.

The circuit will break if exceptionsAllowedBeforeBreaking exceptions that are handled by this policy are raised consecutively.

The circuit will stay broken for the durationOfBreak. Any attempt to execute this policy while the circuit is broken, will immediately throw a BrokenCircuitException containing the exception that broke the circuit.

If the first action after the break duration period results in a handled exception, the circuit will break again for another durationOfBreak; if no exception is thrown, the circuit will reset.

public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, CircuitState, TimeSpan, Context> onBreak, Action<Context> onReset, Action onHalfOpen)

Builds a AsyncPolicy that will function like a Circuit Breaker.

The circuit will break if exceptionsAllowedBeforeBreaking exceptions that are handled by this policy are raised consecutively.

The circuit will stay broken for the durationOfBreak. Any attempt to execute this policy while the circuit is broken, will immediately throw a BrokenCircuitException containing the exception that broke the circuit.

If the first action after the break duration period results in a handled exception, the circuit will break again for another durationOfBreak; if no exception is thrown, the circuit will reset.