CircuitBreakerResilienceStrategy<T>
using Polly.Utils;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.CircuitBreaker
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
internal sealed class CircuitBreakerResilienceStrategy<[System.Runtime.CompilerServices.Nullable(2)] T> : OutcomeResilienceStrategy<T>
{
[System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
0
})]
private readonly Func<OutcomeArguments<T, CircuitBreakerPredicateArguments>, ValueTask<bool>> _handler;
private readonly CircuitStateController<T> _controller;
[System.Runtime.CompilerServices.NullableContext(2)]
public CircuitBreakerResilienceStrategy([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
0
})] Func<OutcomeArguments<T, CircuitBreakerPredicateArguments>, ValueTask<bool>> handler, [System.Runtime.CompilerServices.Nullable(1)] CircuitStateController<T> controller, CircuitBreakerStateProvider stateProvider, CircuitBreakerManualControl manualControl)
{
_handler = handler;
_controller = controller;
stateProvider?.Initialize(() => _controller.CircuitState, () => _controller.LastHandledOutcome);
if (manualControl != null) {
Func<ResilienceContext, Task> onIsolate = delegate(ResilienceContext c) {
<<-ctor>b__2_2>d stateMachine2 = default(<<-ctor>b__2_2>d);
stateMachine2.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine2.<>4__this = this;
stateMachine2.c = c;
stateMachine2.<>1__state = -1;
stateMachine2.<>t__builder.Start<<<-ctor>b__2_2>d>(ref stateMachine2);
return stateMachine2.<>t__builder.Task;
};
Func<ResilienceContext, Task> onReset = delegate(ResilienceContext c) {
<<-ctor>b__2_3>d stateMachine = default(<<-ctor>b__2_3>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.c = c;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start<<<-ctor>b__2_3>d>(ref stateMachine);
return stateMachine.<>t__builder.Task;
};
CircuitStateController<T> controller2 = _controller;
manualControl.Initialize(onIsolate, onReset, controller2.Dispose);
}
}
[AsyncStateMachine(typeof(<ExecuteCore>d__3<>))]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
protected 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__3<TState> stateMachine = default(<ExecuteCore>d__3<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;
}
}
}