Simmy is designed to be composed directly into Polly’sDocumentation 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.
PolicyWrap mechanism alongside your existing resilience policies such as retry, circuit breaker, and fallback. The key principle is straightforward: place the Simmy policy innermost in the wrap. This positioning lets the injected faults and delays propagate outward through your real resilience policies exactly as a genuine failure would in production, giving you an honest test of how your resilience configuration behaves under adverse conditions.
Why Placement Matters
PolicyWrap executes policies from outermost to innermost on the way in, and innermost to outermost on the way out. When a Simmy policy sits at the innermost position it intercepts the call at the last possible moment — subverting the real outbound call and substituting a fault, a result, or a delay. The outer Polly policies (retry, timeout, fallback, circuit breaker) never know the fault was synthetic: they react to it exactly as they would react to a real failure from the downstream dependency.
If you placed the chaos policy outermost, the injected fault would bypass all your resilience policies entirely, which defeats the purpose of testing them.
Synchronous PolicyWrap
fallbackPolicy → timeoutPolicy → chaosLatencyPolicy → someMethod(). If chaosLatencyPolicy injects a 5-second delay, the timeoutPolicy will fire before someMethod() is ever called — which is precisely the scenario you want to validate.
Asynchronous PolicyWrap
Adding Chaos to an Exception Policy Wrap
The same pattern works for fault injection. The retry policy will see the injectedSocketException and apply its retry logic exactly as if the network had failed:
Mixing Multiple Simmy Policies
You can include more than one chaos policy in a wrap. Each is evaluated independently, and you can give each a different injection rate and enabled condition.DI and HttpClientFactory Integration
When policies are configured through dependency injection — for example via ASP.NET Core’sHttpClientFactory — you can insert Simmy policies into an existing PolicyWrap at startup without modifying any of the existing policy configuration code. The typical approach is:
- Retrieve or build your existing array of resilience policies.
- Append a Simmy chaos policy to the end of that array (making it innermost).
- Pass the combined array to
Policy.WrapAsync.
HttpClientFactory applies policies in the order they are added via
AddPolicyHandler, with the last-added policy being innermost. Always add the Simmy policy last in the chain when using HttpClientFactory.Execution Summary
| Wrap position | What it tests |
|---|---|
| Innermost (recommended) | Outer resilience policies (retry, timeout, fallback, circuit breaker) respond to the injected chaos exactly as they would to real failures |
| Outermost | Injected faults bypass all resilience policies — resilience code is not tested |
| Middle | Only policies outside the chaos position are tested; inner policies are bypassed |