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(delegate(ResilienceContext c) {
<<-ctor>b__3_1>d stateMachine2 = default(<<-ctor>b__3_1>d);
stateMachine2.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine2.<>4__this = this;
stateMachine2.c = c;
stateMachine2.<>1__state = -1;
stateMachine2.<>t__builder.Start<<<-ctor>b__3_1>d>(ref stateMachine2);
return stateMachine2.<>t__builder.Task;
}, delegate(ResilienceContext c) {
<<-ctor>b__3_2>d stateMachine = default(<<-ctor>b__3_2>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.c = c;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start<<<-ctor>b__3_2>d>(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
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;
}
}
}