/// <summary> /// Configure result to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="result">A delegate representing the result to inject.</param> public static InjectOutcomeAsyncOptions <TResult> Result <TResult>(this InjectOutcomeAsyncOptions <TResult> options, Func <Context, CancellationToken, Task <TResult> > result) { options.Outcome = result; return(options); }
/// <summary> /// Configure result to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="result">The result to inject</param> public static InjectOutcomeAsyncOptions <TResult> Result <TResult>(this InjectOutcomeAsyncOptions <TResult> options, TResult result) => Result(options, (_, __) => Task.FromResult(result));
/// <summary> /// Configure fault to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="fault">The result to inject</param> public static InjectOutcomeAsyncOptions <Exception> Fault <TResult>(this InjectOutcomeAsyncOptions <Exception> options, Exception fault) => Fault <TResult>(options, (_, __) => Task.FromResult(fault));
/// <summary> /// Configure fault to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="fault">A delegate representing the result to inject.</param> public static InjectOutcomeAsyncOptions <Exception> Fault <TResult>(this InjectOutcomeAsyncOptions <Exception> options, Func <Context, CancellationToken, Task <Exception> > fault) { options.Outcome = fault; return(options); }
internal AsyncInjectOutcomePolicy(InjectOutcomeAsyncOptions <Exception> options) : base(options.InjectionRate, options.Enabled) { _faultProvider = options.Outcome ?? throw new ArgumentNullException(nameof(options.Outcome)); }