[Fix #1378] Adding CloudEventPredicateFactory#1379
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a pluggable CloudEventPredicateFactory SPI so applications can customize how CloudEvents are filtered for event consumption (addressing #1378), and migrates the experimental “func” event-filter predicate support onto that SPI.
Changes:
- Introduces
CloudEventPredicateFactoryand wires it intoWorkflowApplication/AbstractTypeConsumer(ServiceLoader-selected, with a default fallback). - Adds a default factory implementation (
DefaultCloudEventPredicateFactory) and removes the prior envelope-predicate hook fromDefaultCloudEventPredicate. - Adds an experimental func-based predicate implementation (
FuncCloudEventPredicate*) and updates fluent builders to produceEventPropertiesPredicate.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java | Loads/holds CloudEventPredicateFactory and exposes it for consumers to build predicates. |
| impl/core/src/main/java/io/serverlessworkflow/impl/events/CloudEventPredicateFactory.java | New SPI interface for constructing CloudEvent predicates. |
| impl/core/src/main/java/io/serverlessworkflow/impl/events/DefaultCloudEventPredicateFactory.java | Default factory returning DefaultCloudEventPredicate. |
| impl/core/src/main/java/io/serverlessworkflow/impl/events/DefaultCloudEventPredicate.java | Removes envelope-level predicate support; exposes isTrue() for subclass use. |
| impl/core/src/main/java/io/serverlessworkflow/impl/events/AbstractTypeConsumer.java | Switches predicate creation to the factory instead of directly instantiating default predicate. |
| fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/AbstractEventPropertiesBuilder.java | Allows injecting a custom EventProperties instance (for experimental predicate subtype). |
| experimental/types/src/main/resources/META-INF/services/io.serverlessworkflow.impl.events.CloudEventPredicateFactory | Registers experimental func predicate factory via ServiceLoader. |
| experimental/types/src/main/java/io/serverlessworkflow/api/types/func/FuncCloudEventPredicateFactory.java | Factory creating func-aware predicate. |
| experimental/types/src/main/java/io/serverlessworkflow/api/types/func/FuncCloudEventPredicate.java | Predicate extending default behavior with an envelope predicate. |
| experimental/types/src/main/java/io/serverlessworkflow/api/types/func/EventPropertiesPredicate.java | New EventProperties subtype carrying a filter predicate object. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncEventFilterPropertiesBuilder.java | Updates fluent builder to use EventPropertiesPredicate instead of additionalProperties hack. |
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java:246
- WorkflowApplication.Builder introduces a cloudEventPredicateFactory field but there is no corresponding public builder method to set it. As a result, customization is only possible via ServiceLoader, unlike other pluggable components in this Builder (e.g., withEventConsumer, withSchemaValidatorFactory, etc.). Consider adding a withCloudEventPredicateFactory(...) method and only using ServiceLoader when the field is null, to allow programmatic override and match existing Builder patterns.
private Map<String, WorkflowAdditionalObject<?>> additionalObjects = new HashMap<>();
private SecretManager secretManager;
private ConfigManager configManager;
private SchedulerListener schedulerListener;
private Optional<URITemplateResolver> templateResolver;
private Optional<FunctionReader> functionReader;
private URI defaultCatalogURI;
private CloudEventPredicateFactory cloudEventPredicateFactory;
private Builder() {
ServiceLoader.load(NamedWorkflowAdditionalObject.class)
.forEach(a -> additionalObjects.put(a.name(), a));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix serverlessworkflow#1378 Signed-off-by: fjtirado <ftirados@redhat.com>
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.
Fix #1378