fix: Add until predicates to any listeners#1377
Open
ricardozanini wants to merge 1 commit intoserverlessworkflow:mainfrom
Open
fix: Add until predicates to any listeners#1377ricardozanini wants to merge 1 commit intoserverlessworkflow:mainfrom
ricardozanini wants to merge 1 commit intoserverlessworkflow:mainfrom
Conversation
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the listen DSL to support additional until(...) predicate shapes for toAny(...) listeners (plain predicate, context-aware predicate, and filter-aware predicate), and enforces the spec restriction that until is only valid with the any consumption strategy.
Changes:
- Added strategy tracking/validation to reject
until()when used withall()orone()consumption strategies. - Added
until(ContextPredicate, Class)anduntil(FilterPredicate, Class)overloads to the Func listen builders/specs. - Added new tests covering
toAny(...).until(...)predicate evaluation and validating thatuntilwithall/onethrows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/dsl/BaseListenSpec.java | Tracks selected listen strategy and throws if until is used with non-any strategies. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncListenToBuilder.java | Adds until overloads for context/filter predicate functional interfaces. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/BaseFuncListenSpec.java | Adds matching until overloads at the DSL spec layer (and adds predClass null checks). |
| experimental/lambda/src/test/java/io/serverless/workflow/impl/executors/func/ListenUntilValidationTest.java | New tests asserting until is rejected for toAll and toOne. |
| experimental/lambda/src/test/java/io/serverless/workflow/impl/executors/func/ListenUntilCurrentTest.java | New integration tests validating toAny accumulation and the new predicate overloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+104
to
+108
| if (untilStep != null && strategyType != StrategyType.ANY) { | ||
| throw new IllegalStateException( | ||
| "until() is only supported with any() event consumption strategy. " | ||
| + "Current strategy: " | ||
| + strategyType); |
Comment on lines
+48
to
+62
| Objects.requireNonNull(predClass, "predClass"); | ||
| this.setUntilStep(u -> u.until(predicate, predClass)); | ||
| return self(); | ||
| } | ||
|
|
||
| public <T> SELF until(ContextPredicate<T> predicate, Class<T> predClass) { | ||
| Objects.requireNonNull(predicate, "predicate"); | ||
| Objects.requireNonNull(predClass, "predClass"); | ||
| this.setUntilStep(u -> u.until(predicate, predClass)); | ||
| return self(); | ||
| } | ||
|
|
||
| public <T> SELF until(FilterPredicate<T> predicate, Class<T> predClass) { | ||
| Objects.requireNonNull(predicate, "predicate"); | ||
| Objects.requireNonNull(predClass, "predClass"); |
Comment on lines
+48
to
+62
| Objects.requireNonNull(predClass, "predClass"); | ||
| this.setUntilStep(u -> u.until(predicate, predClass)); | ||
| return self(); | ||
| } | ||
|
|
||
| public <T> SELF until(ContextPredicate<T> predicate, Class<T> predClass) { | ||
| Objects.requireNonNull(predicate, "predicate"); | ||
| Objects.requireNonNull(predClass, "predClass"); | ||
| this.setUntilStep(u -> u.until(predicate, predClass)); | ||
| return self(); | ||
| } | ||
|
|
||
| public <T> SELF until(FilterPredicate<T> predicate, Class<T> predClass) { | ||
| Objects.requireNonNull(predicate, "predicate"); | ||
| Objects.requireNonNull(predClass, "predClass"); |
Comment on lines
+48
to
+62
| Objects.requireNonNull(predClass, "predClass"); | ||
| this.setUntilStep(u -> u.until(predicate, predClass)); | ||
| return self(); | ||
| } | ||
|
|
||
| public <T> SELF until(ContextPredicate<T> predicate, Class<T> predClass) { | ||
| Objects.requireNonNull(predicate, "predicate"); | ||
| Objects.requireNonNull(predClass, "predClass"); | ||
| this.setUntilStep(u -> u.until(predicate, predClass)); | ||
| return self(); | ||
| } | ||
|
|
||
| public <T> SELF until(FilterPredicate<T> predicate, Class<T> predClass) { | ||
| Objects.requireNonNull(predicate, "predicate"); | ||
| Objects.requireNonNull(predClass, "predClass"); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it:
toAnyaccumulation and predicate evaluation onuntil.untilis called inallorone.Special notes for reviewers:
Additional information (if needed):