Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Polly-Contrib/Simmy/llms.txt
Use this file to discover all available pages before exploring further.
InjectOutcomeOptions<TResult> and InjectOutcomeAsyncOptions<TResult> are the configuration objects you pass to MonkeyPolicy.InjectException, MonkeyPolicy.InjectResult, and their async counterparts. Both types follow the same fluent builder pattern: you receive a fresh options instance inside the configureOptions callback, chain extension methods to configure the fault or result to inject along with the rate and enabled condition, and the factory validates the fully configured object before constructing the policy. The sync and async variants share the same design; the only difference is that async delegates return Task<T>.
Namespaces
InjectOutcomeOptions<TResult> (sync)
InjectionRate and Enabled delegates from InjectOptionsBase. The internal OutcomeInternal property stores the resolved outcome delegate and is set by the extension methods below.
InjectOutcomeAsyncOptions<TResult> (async)
InjectionRate and Enabled delegates (Task<double> / Task<bool>) from InjectOptionsAsyncBase. The internal Outcome property stores the async outcome delegate.
Fault extension methods (exception injection)
These methods are defined onInjectOutcomeOptionsExtensions and InjectOutcomeAsyncOptionsExtensions. They apply when TResult is Exception.
.Fault(Exception) — sync
Configures a specific exception instance to throw.
The options object being configured (supplied automatically by the fluent chain).
The exception instance that the policy will throw on every triggered injection. The same object is reused across calls; create a new instance via the delegate overload if you need distinct instances.
.Fault(Func<Context, CancellationToken, Exception>) — sync delegate
Configures a delegate that is called at injection-time to produce the exception, giving access to the current Polly Context and CancellationToken.
The options object being configured.
A delegate invoked at injection-time. Receives the Polly execution context and a cancellation token; returns the exception to throw.
.Fault(Exception) — async
Configures a specific exception instance for an async policy.
The async options object being configured.
The exception instance to inject. Internally wrapped in
Task.FromResult(fault)..Fault(Func<Context, CancellationToken, Task<Exception>>) — async delegate
Configures an async delegate that produces the exception at injection-time.
The async options object being configured.
An async delegate that returns a
Task<Exception>. Receives the Polly Context and CancellationToken; useful when the exception type or message must be resolved asynchronously (for example, from a feature flag service).Result extension methods (result injection)
These methods apply whenTResult is a non-exception result type.
.Result<TResult>(TResult) — sync
Configures a fixed result value to return in place of executing the wrapped delegate.
The options object being configured.
The value that the policy returns on every triggered injection, bypassing the wrapped delegate entirely.
.Result<TResult>(Func<Context, CancellationToken, TResult>) — sync delegate
Configures a delegate that produces the result at injection-time.
The options object being configured.
A delegate invoked at injection-time. Receives the Polly
Context and a CancellationToken; returns the TResult value to inject..Result<TResult>(TResult) — async
Configures a fixed result value for an async outcome policy.
The async options object being configured.
The value to return. Internally wrapped in
Task.FromResult(result)..Result<TResult>(Func<Context, CancellationToken, Task<TResult>>) — async delegate
Configures an async delegate that produces the result at injection-time.
The async options object being configured.
An async delegate returning
Task<TResult>. The context and cancellation token allow the injected value to be resolved from an async source such as a configuration store.Inherited base options
BothInjectOutcomeOptions<TResult> and InjectOutcomeAsyncOptions<TResult> inherit activation and rate-control methods from their base classes. These must always be configured — the factory will throw ArgumentNullException if either is missing.
Sync base (InjectOptionsBaseExtensions)
.Enabled() — always on
.Enabled(true).
.Enabled(bool)
Pass
true to activate the policy, false to deactivate it entirely (no chaos is injected regardless of injection rate)..EnabledWhen(Func<Context, CancellationToken, bool>)
A delegate evaluated on every execution. Return
true to allow chaos injection for that call; false to skip it. Useful for environment-flag checks or per-operation-key gating..InjectionRate(double)
A constant rate in the range
[0, 1]. 0 means never inject; 1 means inject on every call. Values outside the range throw an ArgumentOutOfRangeException..InjectionRate(Func<Context, CancellationToken, double>)
A delegate evaluated on each execution to get a dynamic injection rate. Use this to vary chaos intensity at runtime, for example by reading from a feature flag or a shared configuration value.
Async base (InjectOptionsAsyncBaseExtensions)
The async base provides the same .Enabled(), .Enabled(bool), and .InjectionRate(double) overloads as the sync base. It additionally offers async-delegate overloads:
.EnabledWhen(Func<Context, CancellationToken, Task<bool>>)
An async delegate that returns
Task<bool>. Allows the enabled check to call async services such as a remote feature-flag API..InjectionRate(Func<Context, CancellationToken, Task<double>>)
An async delegate returning
Task<double> in the range [0, 1]. Enables dynamically fetching the chaos rate from a remote configuration service.