@@ -190,6 +190,24 @@ void configuringRateAndRetryViaAnnotationsShouldWork() {
190
190
assertEquals (Duration .ofSeconds (3 ), rateLimiter .getRefreshPeriod ());
191
191
}
192
192
193
+ @ Test
194
+ void configuringRateLimitAndGradualRetryViaSuperClassShouldWork () {
195
+ var config = configFor (new GradualRetryAndRateLimitedOnSuperClass ());
196
+ final var retry = config .getRetry ();
197
+ final var testRetry = assertInstanceOf (GenericRetry .class , retry );
198
+ assertEquals (
199
+ BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS ,
200
+ testRetry .getMaxAttempts ());
201
+
202
+ final var rateLimiter = assertInstanceOf (LinearRateLimiter .class , config .getRateLimiter ());
203
+ assertEquals (
204
+ BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
205
+ rateLimiter .getLimitForPeriod ());
206
+ assertEquals (
207
+ Duration .ofSeconds (BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS ),
208
+ rateLimiter .getRefreshPeriod ());
209
+ }
210
+
193
211
@ Test
194
212
void checkingRetryingGraduallyWorks () {
195
213
var config = configFor (new CheckRetryingGraduallyConfiguration ());
@@ -250,6 +268,7 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
250
268
@ ControllerConfiguration (
251
269
dependents = @ Dependent (type = ReadOnlyDependent .class , name = NamedDepReconciler .NAME ))
252
270
private static class NamedDepReconciler implements Reconciler <ConfigMap > {
271
+
253
272
private static final String NAME = "foo" ;
254
273
255
274
@ Override
@@ -325,6 +344,7 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
325
344
}
326
345
327
346
public static class TestRetry implements Retry , AnnotationConfigurable <TestRetryConfiguration > {
347
+
328
348
private int value ;
329
349
330
350
public TestRetry () {}
@@ -347,6 +367,7 @@ public void initFrom(TestRetryConfiguration configuration) {
347
367
@ Target (ElementType .TYPE )
348
368
@ Retention (RetentionPolicy .RUNTIME )
349
369
private @interface TestRetryConfiguration {
370
+
350
371
int value () default 42 ;
351
372
}
352
373
@@ -382,7 +403,30 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
382
403
}
383
404
}
384
405
406
+ @ ControllerConfiguration
407
+ private static class GradualRetryAndRateLimitedOnSuperClass
408
+ extends BaseClassWithGradualRetryAndRateLimited
409
+ implements Reconciler <ConfigMap > {
410
+
411
+ @ Override
412
+ public UpdateControl <ConfigMap > reconcile (ConfigMap resource , Context <ConfigMap > context ) {
413
+ return null ;
414
+ }
415
+ }
416
+
417
+ @ RateLimited (
418
+ maxReconciliations = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
419
+ within = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS )
420
+ @ GradualRetry (maxAttempts = BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS )
421
+ private static class BaseClassWithGradualRetryAndRateLimited {
422
+
423
+ public static final int RATE_LIMITED_MAX_RECONCILIATIONS = 7 ;
424
+ public static final int RATE_LIMITED_WITHIN_SECONDS = 3 ;
425
+ public static final int RETRY_MAX_ATTEMPTS = 3 ;
426
+ }
427
+
385
428
private static class ControllerConfigurationOnSuperClass extends BaseClass {
429
+
386
430
}
387
431
388
432
@ ControllerConfiguration
@@ -443,10 +487,12 @@ private static class ChildCustomAnnotatedDep extends CustomAnnotatedDep {
443
487
444
488
@ Retention (RetentionPolicy .RUNTIME )
445
489
private @interface CustomAnnotation {
490
+
446
491
int value ();
447
492
}
448
493
449
494
private static class CustomConfig {
495
+
450
496
private final int value ;
451
497
452
498
private CustomConfig (int value ) {
@@ -460,6 +506,7 @@ public int getValue() {
460
506
461
507
private static class CustomConfigConverter
462
508
implements ConfigurationConverter <CustomAnnotation , CustomConfig , CustomAnnotatedDep > {
509
+
463
510
static final int CONVERTER_PROVIDED_DEFAULT = 7 ;
464
511
465
512
@ Override
0 commit comments