Skip to content

[Fix #1378] Adding CloudEventPredicateFactory#1379

Merged
fjtirado merged 1 commit into
serverlessworkflow:mainfrom
fjtirado:Fix_#1378
May 11, 2026
Merged

[Fix #1378] Adding CloudEventPredicateFactory#1379
fjtirado merged 1 commit into
serverlessworkflow:mainfrom
fjtirado:Fix_#1378

Conversation

@fjtirado
Copy link
Copy Markdown
Collaborator

Fix #1378

Copilot AI review requested due to automatic review settings May 11, 2026 10:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CloudEventPredicateFactory and wires it into WorkflowApplication/AbstractTypeConsumer (ServiceLoader-selected, with a default fallback).
  • Adds a default factory implementation (DefaultCloudEventPredicateFactory) and removes the prior envelope-predicate hook from DefaultCloudEventPredicate.
  • Adds an experimental func-based predicate implementation (FuncCloudEventPredicate*) and updates fluent builders to produce EventPropertiesPredicate.

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.

Copilot AI review requested due to automatic review settings May 11, 2026 11:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@fjtirado fjtirado merged commit 0a9a29e into serverlessworkflow:main May 11, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CloudEventPredicateFactory

2 participants