[Fix #1406] Allow adding data into lifecycle CloudEvents#1410
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an extensibility point to customize the data payload of lifecycle CloudEvents emitted by the runtime. The previous record-based CE data types are converted to class hierarchies (WorkflowCEData/TaskCEData bases + per-event subclasses) so they can be overridden, and a new WorkflowLifeCycleCloudEventFactory (with default + opt-in InputOutputLifeCycleCloudEventFactory implementations) lets users plug in CE data containing workflow/task input/output.
Changes:
- Introduce
WorkflowLifeCycleCloudEventFactory(+ default and input/output factories) and wire it intoWorkflowApplicationvia a newwithLifeCycleCloudEventFactorybuilder hook. - Convert each
*CEDatarecord to a class extending newWorkflowCEData/TaskCEDatabases, and haveAbstractLifeCyclePublisherbuild CE data through the factory rather than constructing records inline. - Add
WorkflowStartedCEDataWithInput,WorkflowCompletedCEDataWithOutput,TaskStartedCEDataWithInput,TaskCompletedCEDataWithOutputcarryingWorkflowModelpayloads; updateLifeCycleEventsTestto use the input/output factory.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| impl/core/.../WorkflowApplication.java | New lifeCycleCloudEventFactory field, builder setter, default-on-build, and accessor. |
| impl/core/.../lifecycle/ce/AbstractLifeCyclePublisher.java | Replaces inline CE data construction with delegation to the factory; drops local id/pos helpers. |
| impl/core/.../lifecycle/ce/WorkflowLifeCycleCloudEventFactory.java | New factory interface with per-event build methods (and an unused build(CloudEventBuilder) overload). |
| impl/core/.../lifecycle/ce/DefaultLifeCycleCloudEventFactory.java | Default factory producing the base CE data types. |
| impl/core/.../lifecycle/ce/InputOutputLifeCycleCloudEventFactory.java | Opt-in factory returning input/output-bearing CE data for started/completed events. |
| impl/core/.../lifecycle/ce/WorkflowCEData.java, TaskCEData.java | New base classes consolidating common fields and id/pos/ref helpers. |
| impl/core/.../lifecycle/ce/Workflow{Started,Completed,Cancelled,Failed,Resumed,Suspended}CEData.java | Records replaced with classes constructed from events; expose fluent accessors and toString. |
| impl/core/.../lifecycle/ce/WorkflowStatusCEDataEvent.java | Same conversion for the status-change CE data. |
| impl/core/.../lifecycle/ce/Task{Started,Completed,Cancelled,Failed,Resumed,Retried,Suspended}CEData.java | Same conversion for task CE data; TaskRetriedCEData uses getRetriedAt() and TaskResumedCEData.resumedAt is non-final. |
| impl/core/.../lifecycle/ce/{Workflow,Task}{Started,Completed}CEDataW{Input,Output}.java | New subclasses adding WorkflowModel input/output fields. |
| impl/test/.../LifeCycleEventsTest.java | Registers InputOutputLifeCycleCloudEventFactory and asserts on the new W-Output subtypes/WorkflowModel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0513cf7 to
d2a7777
Compare
I do not think we should deprecate any of the getters, we can leave both (the getXXX is needed by Jackson to work, the preferred one should still be the xxx record like ) |
…vents Signed-off-by: fjtirado <ftirados@redhat.com>
Signed-off-by: fjtirado <ftirados@redhat.com>
Fix #1406