Skip to content

Expose a shared enum for lifecycle event kinds #1638

Description

@mcruzdev

sdk-java currently models workflow/task lifecycle events as a set of concrete classes (WorkflowStartedEvent, TaskCompletedEvent, etc., in io.serverlessworkflow.impl.lifecycle) plus a separate class of CloudEvent-type string constants (LifecycleEvents). There's no single enum identifying "what kind of event is this" that consumers can switch/filter on without an instanceof chain or comparing against LifecycleEvents strings.

Downstream, at least two consumers in quarkiverse/quarkus-flow independently reimplement this same taxonomy as local enums:

  • opentelemetry/runtime: WorkflowEventType + TaskEventType, each pairing a constant with its LifecycleEvents id and a fromEvent(WorkflowEvent) classifier via instanceof checks.
  • testing (quarkus-flow-testing): EventType, a flat 16-value enum covering both workflow- and task-level events, used to classify recorded events in test assertions.

Both are hand-written mirrors of the same 16 event kinds sdk-java already defines via its event classes/LifecycleEvents constants.

Request: Expose a canonical enum (e.g. LifecycleEventType) in io.serverlessworkflow.impl.lifecycle, ideally with:

  • One value per concrete WorkflowEvent subtype (workflow- and task-level).
  • A way to classify an arbitrary WorkflowEvent instance to its LifecycleEventType (replacing the instanceof chains each consumer currently writes).
  • A link back to the matching LifecycleEvents CE-id constant, if practical.

This would let consumers (like Quarkus Flow's opentelemetry and testing modules) drop their local duplicates and depend on a single sdk-java-owned source of truth.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions