-
Notifications
You must be signed in to change notification settings - Fork 220
feat: decouple configuration of rate limiting and retry from controller #1317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
74cee29
refactor: do not create a new retry instance if not needed
metacosm 88c17ee
feat: initial reworking of configuration
metacosm 78b8036
fix: make sure we always get a default deactivated rate limiter
metacosm 0d68396
fix: restore backwards compatibility
metacosm 369f1e7
refactor: move RateLimit annotation to proper package
metacosm a5ddb20
refactor: rename RateLimit to be more explicit
metacosm 5b240d3
refactor: clean up
metacosm 876e1d9
chore(tests): add test to check `RetryingGradually` annotation
metacosm aa7017b
fix: better error message
metacosm d11b0e2
put back method for config override
csviri 1c8e6ea
Merge branch 'clean-configuration' of github.com:java-operator-sdk/ja…
csviri b902723
refactor: rename LimitingRateOverPeriod to RateLimited
metacosm d251735
docs: add javadoc
metacosm 8945749
fix: restore backwards compatibility
metacosm 4c36bc1
refactor: rename RetryingGradually to GradualRetry
metacosm 4926cd6
refactor: rename PeriodRateLimiter to LinearRateLimiter
metacosm 41de640
fix: remove duplicated method, add javadoc
metacosm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ork-core/src/main/java/io/javaoperatorsdk/operator/api/config/AnnotationConfigurable.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
public interface AnnotationConfigurable<C extends Annotation> { | ||
void initFrom(C configuration); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...-core/src/main/java/io/javaoperatorsdk/operator/api/config/DefaultRetryConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
public class DefaultRetryConfiguration implements RetryConfiguration { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...amework-core/src/main/java/io/javaoperatorsdk/operator/api/config/RetryConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,14 @@ | |
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent; | ||
import io.javaoperatorsdk.operator.processing.event.rate.LinearRateLimiter; | ||
import io.javaoperatorsdk.operator.processing.event.rate.RateLimiter; | ||
import io.javaoperatorsdk.operator.processing.event.source.controller.ResourceEventFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.VoidGenericFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.VoidOnAddFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.VoidOnUpdateFilter; | ||
import io.javaoperatorsdk.operator.processing.retry.GenericRetry; | ||
import io.javaoperatorsdk.operator.processing.retry.Retry; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE}) | ||
|
@@ -92,13 +96,27 @@ ReconciliationMaxInterval reconciliationMaxInterval() default @ReconciliationMax | |
interval = 10); | ||
|
||
|
||
RateLimit rateLimit() default @RateLimit; | ||
|
||
/** | ||
* Optional list of {@link Dependent} configurations which associate a resource type to a | ||
* {@link io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource} implementation | ||
* | ||
* @return the list of {@link Dependent} configurations | ||
*/ | ||
Dependent[] dependents() default {}; | ||
|
||
/** | ||
* Optional {@link Retry} implementation for the associated controller to use. | ||
* | ||
* @return the class providing the {@link Retry} implementation to use, needs to provide an | ||
* accessible no-arg constructor. | ||
*/ | ||
Class<? extends Retry> retry() default GenericRetry.class; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe have some javadoc here? link how to configur it. |
||
|
||
/** | ||
* Optional {@link RateLimiter} implementation for the associated controller to use. | ||
* | ||
* @return the class providing the {@link RateLimiter} implementation to use, needs to provide an | ||
* accessible no-arg constructor. | ||
*/ | ||
Class<? extends RateLimiter> rateLimiter() default LinearRateLimiter.class; | ||
} |
23 changes: 0 additions & 23 deletions
23
...or-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/RateLimit.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ork-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/RateLimited.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.javaoperatorsdk.operator.processing.event.rate; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE}) | ||
public @interface RateLimited { | ||
|
||
int maxReconciliations(); | ||
|
||
int within(); | ||
|
||
/** | ||
* @return time unit for max delay between reconciliations | ||
*/ | ||
TimeUnit unit() default TimeUnit.SECONDS; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.