You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All the parameters are expressed in a Fluent-builder syntax way.
71
106
72
-
***enabled:** Faults are only injected when returns true.
73
-
***injectionRate:** A decimal between 0 and 1 inclusive. The policy will inject the fault, randomly, that proportion of the time, eg: if 0.2, twenty percent of calls will be randomly affected; if 0.01, one percent of calls; if 1, all calls.
74
-
***fault:** The fault to inject.
75
-
***latency:** The latency to inject.
76
-
***behaviour:** The behaviour to inject.
107
+
### Enabled
108
+
Determines whether the policy is enabled or not.
77
109
78
-
### Context-driven behaviour
110
+
* Configure that the monkey policy is enabled.
111
+
```csharp
112
+
PolicyOptions.Enabled();
113
+
```
79
114
80
-
All parameters are available in a `Func<Context, ...>` form. This allows you to control the chaos injected:
115
+
* Receives a boolean value indicating whether the monkey policy is enabled.
116
+
```csharp
117
+
PolicyOptions.Enabled(bool);
118
+
```
81
119
82
-
+ in a **dynamic** manner: by eg driving the chaos from external configuration files
83
-
+ in a **targeted** manner: by tagging your policy executions with a [`Context.OperationKey`](https://github.com/App-vNext/Polly/wiki/Keys-And-Context-Data#pre-defined-keys-on-context) and introducing chaos targeting particular tagged operations
120
+
* Receives a delegate which can be executed to determine whether the monkey policy should be enabled.
The [example app](https://github.com/Polly-Contrib/Polly.Contrib.SimmyDemo_WebApi) demonstrates both these approaches in practice.
125
+
### InjectionRate
126
+
A decimal between 0 and 1 inclusive. The policy will inject the fault, randomly, that proportion of the time, eg: if 0.2, twenty percent of calls will be randomly affected; if 0.01, one percent of calls; if 1, all calls.
86
127
87
-
# Basic examples
128
+
* Receives a double value between [0, 1] indicating the rate at which this monkey policy should inject chaos.
129
+
```csharp
130
+
PolicyOptions.InjectionRate(Double);
131
+
```
88
132
89
-
## Step 1: Set up the Monkey Policy
133
+
* Receives a delegate which can be executed to determine the rate at which this monkey policy should inject chaos.
All parameters are available in a `Func<Context, ...>` form. This allows you to control the chaos injected:
193
+
194
+
+ in a **dynamic** manner: by eg driving the chaos from external configuration files
195
+
+ in a **targeted** manner: by tagging your policy executions with a [`Context.OperationKey`](https://github.com/App-vNext/Polly/wiki/Keys-And-Context-Data#pre-defined-keys-on-context) and introducing chaos targeting particular tagged operations
196
+
197
+
The [example app](https://github.com/Polly-Contrib/Polly.Contrib.SimmyDemo_WebApi) demonstrates both these approaches in practice.
198
+
199
+
125
200
## Step 2: Execute code through the Monkey Policy
126
201
127
202
```csharp
@@ -137,10 +212,10 @@ var policyWrap = Policy
137
212
policyWrap.Execute(() =>someMethod())
138
213
139
214
// All policies are also available in async forms.
@@ -188,3 +263,4 @@ Simmy was [the brainchild of](https://github.com/App-vNext/Polly/issues/499) [@m
188
263
*[Dylan Reisenberger](http://www.thepollyproject.org/author/dylan/) presents an [intentionally simple example](https://github.com/Polly-Contrib/Polly.Contrib.SimmyDemo_WebApi) .NET Core WebAPI app demonstrating how we can set up Simmy chaos policies for certain environments and without changing any existing configuration code injecting faults or chaos by modifying external configuration.
189
264
190
265
*[Geovanny Alzate Sandoval](https://github.com/vany0114) made a [microservices based sample application](https://github.com/vany0114/chaos-injection-using-simmy) to demonstrate how chaos engineering works with Simmy using chaos policies in a distributed system and how we can inject even a custom behavior given our needs or infrastructure, this time injecting custom behavior to generate chaos in our Service Fabric Cluster.
$NuGetOutput=Invoke-Expression"&`"$NUGET_EXE`" install Cake -Version 0.25.0 -ExcludeVersion"# Pin Cake version to 0.25.0; see https://github.com/App-vNext/Polly/issues/416
0 commit comments