|
1 | 1 | --- |
2 | 2 | title: Event sources and related topics |
3 | | -weight: 47 |
| 3 | +weight: 48 |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | ## Handling Related Events with Event Sources |
@@ -251,51 +251,6 @@ or any non-positive number. |
251 | 251 | The automatic retries are not affected by this feature so a reconciliation will be re-triggered |
252 | 252 | on error, according to the specified retry policy, regardless of this maximum interval setting. |
253 | 253 |
|
254 | | -## Rate Limiting |
255 | | - |
256 | | -It is possible to rate limit reconciliation on a per-resource basis. The rate limit also takes |
257 | | -precedence over retry/re-schedule configurations: for example, even if a retry was scheduled for |
258 | | -the next second but this request would make the resource go over its rate limit, the next |
259 | | -reconciliation will be postponed according to the rate limiting rules. Note that the |
260 | | -reconciliation is never cancelled, it will just be executed as early as possible based on rate |
261 | | -limitations. |
262 | | - |
263 | | -Rate limiting is by default turned **off**, since correct configuration depends on the reconciler |
264 | | -implementation, in particular, on how long a typical reconciliation takes. |
265 | | -(The parallelism of reconciliation itself can be |
266 | | -limited [`ConfigurationService`](https://github.com/java-operator-sdk/java-operator-sdk/blob/ce4d996ee073ebef5715737995fc3d33f4751275/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java#L120-L120) |
267 | | -by configuring the `ExecutorService` appropriately.) |
268 | | - |
269 | | -A default rate limiter implementation is provided, see: |
270 | | -[`PeriodRateLimiter`](https://github.com/java-operator-sdk/java-operator-sdk/blob/ce4d996ee073ebef5715737995fc3d33f4751275/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/PeriodRateLimiter.java#L14-L14) |
271 | | -. |
272 | | -Users can override it by implementing their own |
273 | | -[`RateLimiter`](https://github.com/java-operator-sdk/java-operator-sdk/blob/ce4d996ee073ebef5715737995fc3d33f4751275/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/RateLimiter.java) |
274 | | -and specifying this custom implementation using the `rateLimiter` field of the |
275 | | -`@ControllerConfiguration` annotation. Similarly to the `Retry` implementations, |
276 | | -`RateLimiter` implementations must provide an accessible, no-arg constructor for instantiation |
277 | | -purposes and can further be automatically configured from your own, provided annotation provided |
278 | | -your `RateLimiter` implementation also implements the `AnnotationConfigurable` interface, |
279 | | -parameterized by your custom annotation type. |
280 | | - |
281 | | -To configure the default rate limiter use the `@RateLimited` annotation on your |
282 | | -`Reconciler` class. The following configuration limits each resource to reconcile at most twice |
283 | | -within a 3 second interval: |
284 | | - |
285 | | -```java |
286 | | - |
287 | | -@RateLimited(maxReconciliations = 2, within = 3, unit = TimeUnit.SECONDS) |
288 | | -@ControllerConfiguration |
289 | | -public class MyReconciler implements Reconciler<MyCR> { |
290 | | - |
291 | | -} |
292 | | -``` |
293 | | - |
294 | | -Thus, if a given resource was reconciled twice in one second, no further reconciliation for this |
295 | | -resource will happen before two seconds have elapsed. Note that, since rate is limited on a |
296 | | -per-resource basis, other resources can still be reconciled at the same time, as long, of course, |
297 | | -that they stay within their own rate limits. |
298 | | - |
299 | 254 | ## Optimizing Caches |
300 | 255 |
|
301 | 256 | One of the ideas around the operator pattern is that all the relevant resources are cached, thus reconciliation is |
|
0 commit comments