File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 25
25
import io .javaoperatorsdk .operator .processing .dependent .kubernetes .KubernetesDependentResource ;
26
26
import io .javaoperatorsdk .operator .processing .dependent .kubernetes .KubernetesDependentResourceConfig ;
27
27
import io .javaoperatorsdk .operator .processing .dependent .workflow .Condition ;
28
+ import io .javaoperatorsdk .operator .processing .event .rate .PeriodRateLimiter ;
29
+ import io .javaoperatorsdk .operator .processing .event .rate .RateLimiter ;
28
30
import io .javaoperatorsdk .operator .processing .event .source .controller .ResourceEventFilter ;
29
31
import io .javaoperatorsdk .operator .processing .event .source .controller .ResourceEventFilters ;
30
32
@@ -144,6 +146,17 @@ public Optional<Duration> reconciliationMaxInterval() {
144
146
}
145
147
}
146
148
149
+ @ Override
150
+ public RateLimiter getRateLimiter () {
151
+ if (annotation .rateLimiter () != null ) {
152
+ return new PeriodRateLimiter (Duration .of (annotation .rateLimiter ().refreshPeriod (),
153
+ annotation .rateLimiter ().refreshPeriodTimeUnit ().toChronoUnit ()),
154
+ annotation .rateLimiter ().limitForPeriod ());
155
+ } else {
156
+ return io .javaoperatorsdk .operator .api .config .ControllerConfiguration .super .getRateLimiter ();
157
+ }
158
+ }
159
+
147
160
public static <T > T valueOrDefault (
148
161
ControllerConfiguration controllerConfiguration ,
149
162
Function <ControllerConfiguration , T > mapper ,
Original file line number Diff line number Diff line change 6
6
import java .lang .annotation .Target ;
7
7
8
8
import io .javaoperatorsdk .operator .api .reconciler .dependent .Dependent ;
9
+ import io .javaoperatorsdk .operator .processing .event .rate .PeriodRateLimiter ;
9
10
import io .javaoperatorsdk .operator .processing .event .source .controller .ResourceEventFilter ;
10
11
11
12
@ Retention (RetentionPolicy .RUNTIME )
69
70
ReconciliationMaxInterval reconciliationMaxInterval () default @ ReconciliationMaxInterval (
70
71
interval = 10 );
71
72
73
+
74
+ RateLimiter rateLimiter () default @ RateLimiter (limitForPeriod = PeriodRateLimiter .NO_LIMIT_PERIOD ,
75
+ refreshPeriod = 1 );
76
+
72
77
/**
73
78
* Optional list of {@link Dependent} configurations which associate a resource type to a
74
79
* {@link io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource} implementation
Original file line number Diff line number Diff line change 8
8
9
9
@ Retention (RetentionPolicy .RUNTIME )
10
10
@ Target ({ElementType .TYPE })
11
- public @interface RateLimit {
11
+ public @interface RateLimiter {
12
12
13
13
int limitForPeriod ();
14
14
You can’t perform that action at this time.
0 commit comments