-
Notifications
You must be signed in to change notification settings - Fork 52
Enable workflow restoration for WAITING status #1246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| package io.serverlessworkflow.impl.persistence; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import io.serverlessworkflow.impl.WorkflowStatus; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.TaskCompletedEvent; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.TaskRetriedEvent; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.TaskStartedEvent; | ||||||||||||||||||||||||
|
|
@@ -24,6 +25,7 @@ | |||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.WorkflowFailedEvent; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.WorkflowResumedEvent; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.WorkflowStartedEvent; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.WorkflowStatusEvent; | ||||||||||||||||||||||||
| import io.serverlessworkflow.impl.lifecycle.WorkflowSuspendedEvent; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public class WorkflowPersistenceListener implements WorkflowExecutionListener { | ||||||||||||||||||||||||
|
|
@@ -78,4 +80,12 @@ public void onTaskCompleted(TaskCompletedEvent ev) { | |||||||||||||||||||||||
| public void onTaskRetried(TaskRetriedEvent ev) { | ||||||||||||||||||||||||
| persistenceWriter.taskRetried(ev.workflowContext(), ev.taskContext()); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
| public void onWorkflowStatusChanged(WorkflowStatusEvent ev) { | ||||||||||||||||||||||||
| if (ev.status() == WorkflowStatus.WAITING) { | ||||||||||||||||||||||||
| // Only persist WAITING for now | ||||||||||||||||||||||||
| persistenceWriter.statusChanged(ev.workflowContext(), ev.status()); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+86
to
91
|
||||||||||||||||||||||||
| if (ev.status() == WorkflowStatus.WAITING) { | |
| // Only persist WAITING for now | |
| persistenceWriter.statusChanged(ev.workflowContext(), ev.status()); | |
| } | |
| } | |
| } | |
| // Persist all status changes so a previously persisted WAITING status | |
| // is overwritten when the workflow leaves WAITING. | |
| persistenceWriter.statusChanged(ev.workflowContext(), ev.status()); | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
statusChangedimplementation is a bit harder to read than the surrounding methods due to being on a single long line. Consider wrapping thedoTransaction(...)call in the same style assuspended(...)/taskCompleted(...)to keep formatting consistent and improve readability.