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
Copy file name to clipboardExpand all lines: docs/pipelines/resilience-pipeline-registry.md
+90
Original file line number
Diff line number
Diff line change
@@ -207,6 +207,96 @@ Both `AddReloadToken(...)` and `OnPipelineDisposed(...)` are used to implement t
207
207
208
208
Resource disposal occurs when the registry is disposed of or when the pipeline undergoes changes due to [dynamic reloads](#dynamic-reloads). Upon disposal, all callbacks registered through the `OnPipelineDisposed` method are invoked. However, actual resource disposal is deferred until the pipeline completes all outgoing executions. It's vital to note that dispose callbacks are associated only with a specific instance of the pipeline.
209
209
210
+
### Disposal of encapsulated rate limiters
211
+
212
+
If you are using custom rate limiters and want to dispose them on pipeline reload or when a registry is disposed, then you should use the `OnPipelineDisposed` callback.
213
+
214
+
Consider the following runnable example. It creates a registry with a concurrency strategy and a chained rate limiter strategy (which contains multiple rate limiters):
// unlike other strategies, rate limiters disposed manually
287
+
context.OnPipelineDisposed(() =>
288
+
{
289
+
threadLimiter?.Dispose();
290
+
requestLimiter?.Dispose();
291
+
});
292
+
});
293
+
}
294
+
}
295
+
```
296
+
<!-- endSnippet -->
297
+
298
+
Notice how the rate limiters are disposed manually in the `OnPipelineDisposed` callback.
299
+
210
300
## Complex registry keys
211
301
212
302
Though the pipeline registry supports complex keys, we suggest you use them when defining pipelines with the [Dependency Injection](../advanced/dependency-injection.md) (DI) containers. For further information, see the [section on complex pipeline keys](../advanced/dependency-injection.md#complex-pipeline-keys).
0 commit comments