Class CircuitBreakerSyntax
- Namespace
- Polly
- Assembly
- Polly.dll
Fluent API for defining a Circuit Breaker Policy.
public static class CircuitBreakerSyntax
- Inheritance
-
CircuitBreakerSyntax
- Inherited Members
Methods
CircuitBreaker(PolicyBuilder, int, TimeSpan)
Builds a Policy 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 CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak)
Parameters
policyBuilderPolicyBuilderThe policy builder.
exceptionsAllowedBeforeBreakingintThe number of exceptions that are allowed before opening the circuit.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
Returns
- CircuitBreakerPolicy
The policy instance.
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
exceptionsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
CircuitBreaker(PolicyBuilder, int, TimeSpan, Action<Exception, TimeSpan, Context>, Action<Context>)
Builds a Policy 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 CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan, Context> onBreak, Action<Context> onReset)
Parameters
policyBuilderPolicyBuilderThe policy builder.
exceptionsAllowedBeforeBreakingintThe number of exceptions that are allowed before opening the circuit.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<Exception, TimeSpan, Context>The action to call when the circuit transitions to an Open state.
onResetAction<Context>The action to call when the circuit resets to a Closed state.
Returns
- CircuitBreakerPolicy
The policy instance.
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
exceptionsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
CircuitBreaker(PolicyBuilder, int, TimeSpan, Action<Exception, TimeSpan, Context>, Action<Context>, Action)
Builds a Policy 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 CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan, Context> onBreak, Action<Context> onReset, Action onHalfOpen)
Parameters
policyBuilderPolicyBuilderThe policy builder.
exceptionsAllowedBeforeBreakingintThe number of exceptions that are allowed before opening the circuit.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<Exception, TimeSpan, Context>The action to call when the circuit transitions to an Open state.
onResetAction<Context>The action to call when the circuit resets to a Closed state.
onHalfOpenActionThe action to call when the circuit transitions to HalfOpen state, ready to try action executions again.
Returns
- CircuitBreakerPolicy
The policy instance.
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
exceptionsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
- ArgumentNullException
onHalfOpen
CircuitBreaker(PolicyBuilder, int, TimeSpan, Action<Exception, TimeSpan>, Action)
Builds a Policy 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 CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan> onBreak, Action onReset)
Parameters
policyBuilderPolicyBuilderThe policy builder.
exceptionsAllowedBeforeBreakingintThe number of exceptions that are allowed before opening the circuit.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<Exception, TimeSpan>The action to call when the circuit transitions to an Open state.
onResetActionThe action to call when the circuit resets to a Closed state.
Returns
- CircuitBreakerPolicy
The policy instance.
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
exceptionsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
CircuitBreaker(PolicyBuilder, int, TimeSpan, Action<Exception, TimeSpan>, Action, Action)
Builds a Policy 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 CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<Exception, TimeSpan> onBreak, Action onReset, Action onHalfOpen)
Parameters
policyBuilderPolicyBuilderThe policy builder.
exceptionsAllowedBeforeBreakingintThe number of exceptions that are allowed before opening the circuit.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<Exception, TimeSpan>The action to call when the circuit transitions to an Open state.
onResetActionThe action to call when the circuit resets to a Closed state.
onHalfOpenActionThe action to call when the circuit transitions to HalfOpen state, ready to try action executions again.
Returns
- CircuitBreakerPolicy
The policy instance.
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
exceptionsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset