Class CircuitBreakerTResultSyntax
- Namespace
- Polly
- Assembly
- Polly.dll
Fluent API for defining a Circuit Breaker Policy.
public static class CircuitBreakerTResultSyntax
- Inheritance
-
CircuitBreakerTResultSyntax
- Inherited Members
Methods
CircuitBreaker<TResult>(PolicyBuilder<TResult>, int, TimeSpan)
Builds a Policy that will function like a Circuit Breaker.
The circuit will break if handledEventsAllowedBeforeBreaking
exceptions or results that are handled by this policy are encountered 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 or result
that broke the circuit.
If the first action after the break duration period results in a handled exception or result, the circuit will break
again for another durationOfBreak
; if no exception or handled result is encountered, the circuit will reset.
public static CircuitBreakerPolicy<TResult> CircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
handledEventsAllowedBeforeBreaking
intThe number of exceptions or handled results that are allowed before opening the circuit.
durationOfBreak
TimeSpanThe duration the circuit will stay open before resetting.
Returns
- CircuitBreakerPolicy<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
handledEventsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
CircuitBreaker<TResult>(PolicyBuilder<TResult>, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan, Context>, Action<Context>)
Builds a Policy that will function like a Circuit Breaker.
The circuit will break if handledEventsAllowedBeforeBreaking
exceptions or results that are handled by this policy are encountered 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 or result
that broke the circuit.
If the first action after the break duration period results in a handled exception or result, the circuit will break
again for another durationOfBreak
; if no exception or handled result is encountered, the circuit will reset.
public static CircuitBreakerPolicy<TResult> CircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan, Context> onBreak, Action<Context> onReset)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
handledEventsAllowedBeforeBreaking
intThe number of exceptions or handled results that are allowed before opening the circuit.
durationOfBreak
TimeSpanThe duration the circuit will stay open before resetting.
onBreak
Action<DelegateResult<TResult>, TimeSpan, Context>The action to call when the circuit transitions to an Open state.
onReset
Action<Context>The action to call when the circuit resets to a Closed state.
Returns
- CircuitBreakerPolicy<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
handledEventsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
CircuitBreaker<TResult>(PolicyBuilder<TResult>, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan, Context>, Action<Context>, Action)
Builds a Policy that will function like a Circuit Breaker.
The circuit will break if handledEventsAllowedBeforeBreaking
exceptions or results that are handled by this policy are encountered 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 or result
that broke the circuit.
If the first action after the break duration period results in a handled exception or result, the circuit will break
again for another durationOfBreak
; if no exception or handled result is encountered, the circuit will reset.
public static CircuitBreakerPolicy<TResult> CircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan, Context> onBreak, Action<Context> onReset, Action onHalfOpen)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
handledEventsAllowedBeforeBreaking
intThe number of exceptions or handled results that are allowed before opening the circuit.
durationOfBreak
TimeSpanThe duration the circuit will stay open before resetting.
onBreak
Action<DelegateResult<TResult>, TimeSpan, Context>The action to call when the circuit transitions to an Open state.
onReset
Action<Context>The action to call when the circuit resets to a Closed state.
onHalfOpen
ActionThe action to call when the circuit transitions to HalfOpen state, ready to try action executions again.
Returns
- CircuitBreakerPolicy<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
handledEventsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
- ArgumentNullException
onHalfOpen
CircuitBreaker<TResult>(PolicyBuilder<TResult>, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan>, Action)
Builds a Policy that will function like a Circuit Breaker.
The circuit will break if handledEventsAllowedBeforeBreaking
exceptions or results that are handled by this policy are encountered 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 or result
that broke the circuit.
If the first action after the break duration period results in a handled exception or result, the circuit will break
again for another durationOfBreak
; if no exception or handled result is encountered, the circuit will reset.
public static CircuitBreakerPolicy<TResult> CircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan> onBreak, Action onReset)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
handledEventsAllowedBeforeBreaking
intThe number of exceptions or handled results that are allowed before opening the circuit.
durationOfBreak
TimeSpanThe duration the circuit will stay open before resetting.
onBreak
Action<DelegateResult<TResult>, TimeSpan>The action to call when the circuit transitions to an Open state.
onReset
ActionThe action to call when the circuit resets to a Closed state.
Returns
- CircuitBreakerPolicy<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
handledEventsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
CircuitBreaker<TResult>(PolicyBuilder<TResult>, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan>, Action, Action)
Builds a Policy that will function like a Circuit Breaker.
The circuit will break if handledEventsAllowedBeforeBreaking
exceptions or results that are handled by this policy are encountered 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 or result
that broke the circuit.
If the first action after the break duration period results in a handled exception or result, the circuit will break
again for another durationOfBreak
; if no exception or handled result is encountered, the circuit will reset.
public static CircuitBreakerPolicy<TResult> CircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan> onBreak, Action onReset, Action onHalfOpen)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
handledEventsAllowedBeforeBreaking
intThe number of exceptions or handled results that are allowed before opening the circuit.
durationOfBreak
TimeSpanThe duration the circuit will stay open before resetting.
onBreak
Action<DelegateResult<TResult>, TimeSpan>The action to call when the circuit transitions to an Open state.
onReset
ActionThe action to call when the circuit resets to a Closed state.
onHalfOpen
ActionThe action to call when the circuit transitions to HalfOpen state, ready to try action executions again.
Returns
- CircuitBreakerPolicy<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
handledEventsAllowedBeforeBreaking;Value must be greater than zero.
- ArgumentNullException
onBreak
- ArgumentNullException
onReset