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.
MonkeyPolicy is the single static entry-point you use to build every Simmy chaos policy. It is a partial class split across several files in the Polly.Contrib.Simmy namespace, but from a consumer’s perspective it exposes one consistent fluent factory API: call the appropriate Inject* method, pass a configuration delegate, and receive a ready-to-use Polly policy. Every factory method validates that the options object is fully configured before constructing the policy, so misconfigured policies are detected at build-time rather than at execution-time.
Namespace
Base classes
Simmy defines four abstract base classes that the concrete policy types inherit from. You do not construct these directly; they are the common building blocks that carry theInjectionRate and Enabled delegates evaluated on every policy execution.
MonkeyPolicy
Policy and stores synchronous InjectionRate and Enabled delegates.
| Property | Type | Description |
|---|---|---|
InjectionRate | Func<Context, CancellationToken, double> | Returns the current chaos injection rate (0–1). |
Enabled | Func<Context, CancellationToken, bool> | Returns whether the policy is active for this execution. |
MonkeyPolicy<TResult>
TResult.
AsyncMonkeyPolicy
InjectionRate and Enabled delegates both return Task<T> to allow awaitable configuration logic.
| Property | Type | Description |
|---|---|---|
InjectionRate | Func<Context, CancellationToken, Task<double>> | Async delegate returning the injection rate. |
Enabled | Func<Context, CancellationToken, Task<bool>> | Async delegate returning whether the policy is active. |
AsyncMonkeyPolicy<TResult>
TResult.
Interfaces
IMonkeyPolicy
IsPolicy so monkey policies can be treated uniformly alongside other Polly policies.
IMonkeyPolicy<TResult>
TResult.
Synchronous factory methods
InjectException
Builds an InjectOutcomePolicy that throws an exception before the wrapped delegate executes whenever the policy is enabled and a random number falls within the configured injection rate.
A callback that receives a fresh
InjectOutcomeOptions<Exception> and must configure at minimum .Fault(...), .InjectionRate(...), and .Enabled(...) before returning.A synchronous Polly policy that injects the configured exception.
InjectResult<TResult> (result overload)
Builds an InjectOutcomePolicy<TResult> that returns a fake result value instead of executing the wrapped delegate.
A callback that configures a fake
TResult value via .Result(...), plus .InjectionRate(...) and .Enabled(...).A typed synchronous policy that short-circuits with the configured result.
InjectResult<TResult> (exception overload)
Builds an InjectOutcomePolicy<TResult> that throws an exception in a context where a TResult is expected, configured from an InjectOutcomeOptions<Exception>.
A callback that configures an exception fault via
.Fault(...) while the returned policy is typed as InjectOutcomePolicy<TResult>.A typed synchronous policy that throws the configured exception.
InjectLatency
Builds an InjectLatencyPolicy that sleeps for the configured duration before the wrapped delegate executes.
A callback that sets a
TimeSpan delay via .Latency(...), plus .InjectionRate(...) and .Enabled(...).A synchronous policy that injects latency before each execution.
InjectLatency<TResult>
Builds an InjectLatencyPolicy<TResult> — the typed variant for delegates returning TResult.
Same configuration callback as the non-generic overload; the latency configuration is identical, only the policy type differs.
A typed synchronous latency policy.
InjectBehaviour
Builds an InjectBehaviourPolicy that executes an arbitrary side-effect action before the wrapped delegate.
A callback that registers a side-effect via
.Behaviour(...), plus .InjectionRate(...) and .Enabled(...).A synchronous policy that runs the configured behaviour before every guarded call.
Asynchronous factory methods
InjectExceptionAsync
Builds an AsyncInjectOutcomePolicy that asynchronously throws a configured exception.
A callback that configures an exception via
.Fault(...), plus async-capable .InjectionRate(...) and .Enabled(...) delegates.An asynchronous Polly policy that injects the configured exception.
InjectResultAsync<TResult> (result overload)
Builds an AsyncInjectOutcomePolicy<TResult> that returns a fake result asynchronously.
A callback that configures a fake result via
.Result(...) and sets async injection-rate and enabled delegates.A typed asynchronous policy that short-circuits with the configured result.
InjectResultAsync<TResult> (exception overload)
Builds an AsyncInjectOutcomePolicy<TResult> that throws an exception in a context where a TResult is expected, configured from an InjectOutcomeAsyncOptions<Exception>.
A callback that configures an exception fault via
.Fault(...) while the returned policy is typed as AsyncInjectOutcomePolicy<TResult>.A typed asynchronous policy that throws the configured exception.
InjectLatencyAsync
Builds an AsyncInjectLatencyPolicy that introduces an async delay before execution.
A callback that sets a
TimeSpan or async delegate via .Latency(...), plus .InjectionRate(...) and .Enabled(...).An asynchronous policy that injects a delay before each execution.
InjectLatencyAsync<TResult>
Builds an AsyncInjectLatencyPolicy<TResult> — the typed async variant.
Same as the non-generic async overload; returns a policy typed to
TResult.A typed asynchronous latency policy.
InjectBehaviourAsync
Builds an AsyncInjectBehaviourPolicy that runs an async side-effect before the wrapped delegate.
A callback that registers an async side-effect via
.Behaviour(...), plus .InjectionRate(...) and .Enabled(...).An asynchronous policy that executes the configured behaviour before each guarded call.