Class AdvancedCircuitBreakerTResultSyntax
- Namespace
- Polly
- Assembly
- Polly.dll
Fluent API for defining a Circuit Breaker Policy.
public static class AdvancedCircuitBreakerTResultSyntax
- Inheritance
-
AdvancedCircuitBreakerTResultSyntax
- Inherited Members
Methods
AdvancedCircuitBreaker<TResult>(PolicyBuilder<TResult>, double, TimeSpan, int, TimeSpan)
Builds a Policy that will function like a Circuit Breaker.
The circuit will break if, within any timeslice of duration samplingDuration, the proportion of actions resulting in a handled exception or result exceeds failureThreshold, provided also that the number of actions through the circuit in the timeslice is at least minimumThroughput.
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> AdvancedCircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak)
Parameters
policyBuilderPolicyBuilder<TResult>The policy builder.
failureThresholddoubleThe failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure).
samplingDurationTimeSpanThe duration of the timeslice over which failure ratios are assessed.
minimumThroughputintThe minimum throughput: this many actions or more must pass through the circuit in the timeslice, for statistics to be considered significant and the circuit-breaker to come into action.
durationOfBreakTimeSpanThe 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
failureThreshold;Value must be greater than zero
- ArgumentOutOfRangeException
failureThreshold;Value must be less than or equal to one
- ArgumentOutOfRangeException
samplingDuration;Value must be equal to or greater than the minimum resolution of the CircuitBreaker timer
- ArgumentOutOfRangeException
minimumThroughput;Value must be greater than one
- ArgumentOutOfRangeException
durationOfBreak;Value must be greater than zero
AdvancedCircuitBreaker<TResult>(PolicyBuilder<TResult>, double, TimeSpan, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan, Context>, Action<Context>)
The circuit will break if, within any timeslice of duration samplingDuration, the proportion of actions resulting in a handled exception or result exceeds failureThreshold, provided also that the number of actions through the circuit in the timeslice is at least minimumThroughput.
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> AdvancedCircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan, Context> onBreak, Action<Context> onReset)
Parameters
policyBuilderPolicyBuilder<TResult>The policy builder.
failureThresholddoubleThe failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure.
samplingDurationTimeSpanThe duration of the timeslice over which failure ratios are assessed.
minimumThroughputintThe minimum throughput: this many actions or more must pass through the circuit in the timeslice, for statistics to be considered significant and the circuit-breaker to come into action.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<DelegateResult<TResult>, 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<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
failureThreshold;Value must be greater than zero
- ArgumentOutOfRangeException
failureThreshold;Value must be less than or equal to one
- ArgumentOutOfRangeException
samplingDuration;Value must be equal to or greater than the minimum resolution of the CircuitBreaker timer
- ArgumentOutOfRangeException
minimumThroughput;Value must be greater than one
- ArgumentOutOfRangeException
durationOfBreak;Value must be greater than zero
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
AdvancedCircuitBreaker<TResult>(PolicyBuilder<TResult>, double, TimeSpan, 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, within any timeslice of duration samplingDuration, the proportion of actions resulting in a handled exception or result exceeds failureThreshold, provided also that the number of actions through the circuit in the timeslice is at least minimumThroughput.
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> AdvancedCircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan, Context> onBreak, Action<Context> onReset, Action onHalfOpen)
Parameters
policyBuilderPolicyBuilder<TResult>The policy builder.
failureThresholddoubleThe failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure.
samplingDurationTimeSpanThe duration of the timeslice over which failure ratios are assessed.
minimumThroughputintThe minimum throughput: this many actions or more must pass through the circuit in the timeslice, for statistics to be considered significant and the circuit-breaker to come into action.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<DelegateResult<TResult>, 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<TResult>
The policy instance.
Type Parameters
TResultThe return type of delegates which may be executed through the policy.
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
failureThreshold;Value must be greater than zero
- ArgumentOutOfRangeException
failureThreshold;Value must be less than or equal to one
- ArgumentOutOfRangeException
samplingDuration;Value must be equal to or greater than the minimum resolution of the CircuitBreaker timer
- ArgumentOutOfRangeException
minimumThroughput;Value must be greater than one
- ArgumentOutOfRangeException
durationOfBreak;Value must be greater than zero
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
- ArgumentNullException
onHalfOpen
AdvancedCircuitBreaker<TResult>(PolicyBuilder<TResult>, double, TimeSpan, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan>, Action)
The circuit will break if, within any timeslice of duration samplingDuration, the proportion of actions resulting in a handled exception or result exceeds failureThreshold, provided also that the number of actions through the circuit in the timeslice is at least minimumThroughput.
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> AdvancedCircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan> onBreak, Action onReset)
Parameters
policyBuilderPolicyBuilder<TResult>The policy builder.
failureThresholddoubleThe failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure.
samplingDurationTimeSpanThe duration of the timeslice over which failure ratios are assessed.
minimumThroughputintThe minimum throughput: this many actions or more must pass through the circuit in the timeslice, for statistics to be considered significant and the circuit-breaker to come into action.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<DelegateResult<TResult>, 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<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
failureThreshold;Value must be greater than zero
- ArgumentOutOfRangeException
failureThreshold;Value must be less than or equal to one
- ArgumentOutOfRangeException
samplingDuration;Value must be equal to or greater than the minimum resolution of the CircuitBreaker timer
- ArgumentOutOfRangeException
minimumThroughput;Value must be greater than one
- ArgumentOutOfRangeException
durationOfBreak;Value must be greater than zero
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
AdvancedCircuitBreaker<TResult>(PolicyBuilder<TResult>, double, TimeSpan, int, TimeSpan, Action<DelegateResult<TResult>, TimeSpan>, Action, Action)
The circuit will break if, within any timeslice of duration samplingDuration, the proportion of actions resulting in a handled exception or result exceeds failureThreshold, provided also that the number of actions through the circuit in the timeslice is at least minimumThroughput.
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> AdvancedCircuitBreaker<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan> onBreak, Action onReset, Action onHalfOpen)
Parameters
policyBuilderPolicyBuilder<TResult>The policy builder.
failureThresholddoubleThe failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure.
samplingDurationTimeSpanThe duration of the timeslice over which failure ratios are assessed.
minimumThroughputintThe minimum throughput: this many actions or more must pass through the circuit in the timeslice, for statistics to be considered significant and the circuit-breaker to come into action.
durationOfBreakTimeSpanThe duration the circuit will stay open before resetting.
onBreakAction<DelegateResult<TResult>, 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<TResult>
The policy instance.
Type Parameters
TResult
Remarks
(see "Release It!" by Michael T. Nygard fi)
Exceptions
- ArgumentOutOfRangeException
failureThreshold;Value must be greater than zero
- ArgumentOutOfRangeException
failureThreshold;Value must be less than or equal to one
- ArgumentOutOfRangeException
samplingDuration;Value must be equal to or greater than the minimum resolution of the CircuitBreaker timer
- ArgumentOutOfRangeException
minimumThroughput;Value must be greater than one
- ArgumentOutOfRangeException
durationOfBreak;Value must be greater than zero
- ArgumentNullException
onBreak
- ArgumentNullException
onReset
- ArgumentNullException
onHalfOpen