CircuitBreakerResilienceStrategy<T>
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.CircuitBreaker
{
[System.Runtime.CompilerServices.NullableContext(2)]
[System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
internal sealed class CircuitBreakerResilienceStrategy<T> : ResilienceStrategy<T>, IDisposable
{
[System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
0
})]
private readonly Func<CircuitBreakerPredicateArguments<T>, ValueTask<bool>> _handler;
[System.Runtime.CompilerServices.Nullable(1)]
private readonly CircuitStateController<T> _controller;
private readonly IDisposable _manualControlRegistration;
public CircuitBreakerResilienceStrategy([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
0
})] Func<CircuitBreakerPredicateArguments<T>, ValueTask<bool>> handler, [System.Runtime.CompilerServices.Nullable(1)] CircuitStateController<T> controller, CircuitBreakerStateProvider stateProvider, CircuitBreakerManualControl manualControl)
{
_handler = handler;
_controller = controller;
stateProvider?.Initialize(() => _controller.CircuitState);
_manualControlRegistration = manualControl?.Initialize(_controller.IsolateCircuitAsync, _controller.CloseCircuitAsync);
}
public void Dispose()
{
_manualControlRegistration?.Dispose();
_controller.Dispose();
}
[System.Runtime.CompilerServices.NullableContext(1)]
[AsyncStateMachine(typeof(<ExecuteCore>d__5<>))]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
protected internal override ValueTask<Outcome<T>> ExecuteCore<[System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
0,
1
})] Func<ResilienceContext, TState, ValueTask<Outcome<T>>> callback, ResilienceContext context, TState state)
{
<ExecuteCore>d__5<TState> stateMachine = default(<ExecuteCore>d__5<TState>);
stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<T>>.Create();
stateMachine.<>4__this = this;
stateMachine.callback = callback;
stateMachine.context = context;
stateMachine.state = state;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
}
}