feat(workflow): delay action with deferred job queue#35
Open
mpge wants to merge 1 commit intofeat/workflow-executorfrom
Open
feat(workflow): delay action with deferred job queue#35mpge wants to merge 1 commit intofeat/workflow-executorfrom
mpge wants to merge 1 commit intofeat/workflow-executorfrom
Conversation
Splits workflow execution around a `delay N` step: actions before the delay run inline, remaining actions are persisted as a DeferredWorkflowJob with runAt = now + N seconds. A @scheduled poller on WorkflowExecutorService (60s cadence by default, matching SnoozeScheduler and the NestJS reference) picks up due pending jobs, re-invokes the executor with the stored remainingActions, and marks the row done/failed (retained for audit). Ports the behavior from escalated-nestjs#26. The new entity has a composite (status, run_at) index for efficient polling. Stacked on feat/workflow-executor.
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.
Summary
Adds the `delay` workflow action as a ninth entry in the catalog. Splits execution around a wait clause: actions before the delay run inline, remaining actions are persisted as a `DeferredWorkflowJob` row with `runAt = now + N seconds`. A `@Scheduled` poller on `WorkflowExecutorService` (60s cadence, matching SnoozeScheduler) picks up due pending jobs, rehydrates the ticket, resumes the saved action sequence, and flips status to `done` / `failed`. Rows are audit-retained.
What's added
Why
Ports escalated-nestjs#26 to the Spring plugin. The other eight workflow actions already in `feat/workflow-executor` (`change_priority`, `change_status`, `assign_agent`, `set_department`, `add_tag`, `remove_tag`, `add_note`, `insert_canned_reply`) now have parity with the NestJS reference; `delay` was the last missing entry.
The H2 test DB uses `ddl-auto=create-drop`, so the new entity's schema is auto-generated in tests without a migration. A production Flyway migration can follow as a separate PR once this pattern is accepted.
Base / Stacking
Stacked on `feat/workflow-executor` (PR #21). CI won't exercise this branch until that base merges and this rebases onto `main`.
Test plan