Skip to content

Commit e976fb8

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 1e60993 commit e976fb8

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

docs/content/en/docs/documentation/rate-limiting.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Rate limiting
33
weight: 47
44
---
55

6-
It is possible to rate limit reconciliation on a per-resource basis. The rate limit also takes
6+
It is possible to rate limit reconciliation on a per-resource basis. The rate limit takes
77
precedence over retry/re-schedule configurations: for example, even if retry would re-schedule a reconciliation
88
but this request would make the resource go over its rate limit, the next
99
reconciliation will be postponed according to the rate limiting rules. Note that the
@@ -16,26 +16,15 @@ implementation, in particular, on how long a typical reconciliation takes.
1616
[`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)
1717
by configuring the `ExecutorService` appropriately.)
1818

19-
We provide a generic rate limiter implementation:
20-
[`LinearRateLimiter`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/LinearRateLimiter.java)
21-
.
22-
You can provide your own rate limiter by implementing the [`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)
23-
interface.
19+
## Default Rate Limiter
2420

25-
You can set this custom implementation using explicit [configuration](operations/configuration.md) or using the `rateLimiter`
26-
field of the `@ControllerConfiguration` annotation.
27-
For the annotation approach, similarly to `Retry` implementations,
28-
`RateLimiter` implementations must provide an accessible, no-arg constructor for instantiation
29-
purposes and can further be automatically configured from your own annotation, provided that
30-
your `RateLimiter` implementation also implements the `AnnotationConfigurable` interface,
31-
parameterized by your custom annotation type.
21+
We provide a generic rate limiter implementation:
22+
[`LinearRateLimiter`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/LinearRateLimiter.java).
3223

33-
To configure the default rate limiter, use the `@RateLimited` annotation on your
34-
`Reconciler` class. The following configuration limits each resource to reconcile at most twice
35-
within a 3 second interval:
24+
To configure it, use the `@RateLimited` annotation on your `Reconciler` class. The following
25+
configuration limits each resource to reconcile at most twice within a 3 second interval:
3626

3727
```java
38-
3928
@RateLimited(maxReconciliations = 2, within = 3, unit = TimeUnit.SECONDS)
4029
@ControllerConfiguration
4130
public class MyReconciler implements Reconciler<MyCR> {
@@ -44,6 +33,21 @@ public class MyReconciler implements Reconciler<MyCR> {
4433
```
4534

4635
Thus, if a given resource was reconciled twice in one second, no further reconciliation for this
47-
resource will happen before two seconds have elapsed. Note that, since rate is limited on a
48-
per-resource basis, other resources can still be reconciled at the same time, as long, of course,
49-
that they stay within their own rate limits.
36+
resource will happen before two seconds have elapsed. Note that, since rate limiting is on a
37+
per-resource basis, other resources can still be reconciled at the same time, as long as
38+
they stay within their own rate limits.
39+
40+
## Custom Rate Limiter
41+
42+
You can provide your own rate limiter by implementing the
43+
[`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)
44+
interface and setting it either through:
45+
46+
- explicit [configuration](operations/configuration.md), or
47+
- the `rateLimiter` field of the `@ControllerConfiguration` annotation.
48+
49+
For the annotation approach, similarly to `Retry` implementations,
50+
`RateLimiter` implementations must provide an accessible, no-arg constructor for instantiation
51+
purposes and can further be automatically configured from your own annotation, provided that
52+
your `RateLimiter` implementation also implements the `AnnotationConfigurable` interface,
53+
parameterized by your custom annotation type.

0 commit comments

Comments
 (0)