-
Notifications
You must be signed in to change notification settings - Fork 235
feat: distinct latest resource collector #3130
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
base: next
Are you sure you want to change the base?
Conversation
...-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtils.java
Outdated
Show resolved
Hide resolved
...-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtils.java
Outdated
Show resolved
Hide resolved
...mework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtilsTest.java
Show resolved
Hide resolved
...mework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtilsTest.java
Show resolved
Hide resolved
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
…tor/api/reconciler/ReconcileUtils.java Co-authored-by: Martin Stefanko <xstefank122@gmail.com>
03cbf4c to
d7e21c5
Compare
| * @param <T> the type of HasMetadata objects | ||
| * @return a collector that produces a List of deduplicated Kubernetes objects | ||
| */ | ||
| public static <T extends HasMetadata> Collector<T, ?, List<T>> latestDistinctList() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why this method or the set variant are needed or even useful. The semantic should be a Set since instances should be unique, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Set variant is needed since we are covering the use case whern there are multiple event sources for same type without distinct set of resource watched, so we returning the latest of those.
I added List just for convinience. If somebody would prefer working above Lists, that is quite common I beleive, but you are right that the semantically Set is the correct one.
| new ResourceID(resource.getMetadata().getName(), resource.getMetadata().getNamespace()), | ||
| resource -> resource, | ||
| (existing, replacement) -> | ||
| compareResourceVersions(existing, replacement) >= 0 ? existing : replacement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @metacosm this is the point to keep of this PR, just to keep the latest
No description provided.