- Notifications
You must be signed in to change notification settings - Fork 1
π Make the executor lock the only way a run's lifecycle moves#466
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
05d5039dc9f73c7968f2ac7384b5c4228a5d1e1b3e45043dcd6d4e9fd1220529ab55507cd080e35c14327c8a41bb83e519e271ac4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -2,7 +2,7 @@ | ||||||
| * `xmd workflow status`, `list` and `history` β reading a run without running it. | ||||||
| * | ||||||
| * These commands answer from immutable lifecycle snapshots. Nothing here opens | ||||||
| * a writable database, acquires a lease, replays, attaches a Workspace, | ||||||
| * a writable database, acquires the executor lock, replays, attaches a Workspace, | ||||||
| * materializes a root, imports a document or contacts a provider: what a | ||||||
| * reading command may do is read. | ||||||
| * | ||||||
| @@ -25,7 +25,7 @@ | ||||||
| import { scoped } from "effection"; | ||||||
| import type { Operation } from "effection"; | ||||||
| import { WorkflowLifecycle, WorkflowLifecycleProviderError } from "@executablemd/workflow"; | ||||||
| import { WorkflowLifecycle } from "@executablemd/workflow"; | ||||||
| import type { | ||||||
| WorkflowHistoryEntry, | ||||||
| WorkflowLifecycleSnapshot, | ||||||
| @@ -76,26 +76,25 @@ export function runWorkflowManagement( | ||||||
| write(request.json ? json(entries.value) : renderHistory(entries.value)); | ||||||
| return { exitCode: 0 }; | ||||||
| } | ||||||
| case "cancel": | ||||||
| case "cancel": { | ||||||
| const cancelled = yield* WorkflowLifecycle.operations.cancel(request.runId); | ||||||
| if (!cancelled.ok) { | ||||||
| return refuse(cancelled.error); | ||||||
| } | ||||||
| // The command reports its own request, not the run's outcome: asking | ||||||
| // for a cancellation and getting one is success, however terminal the | ||||||
| // status it left behind. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant comment β restates what the code does.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant comment β restates what the code does.
Suggested change
| ||||||
| write(`workflow cancel: ${cancelled.value.runId} (${cancelled.value.status})`); | ||||||
| return { exitCode: 0 }; | ||||||
| } | ||||||
| case "delete": { | ||||||
| // An operation this host installs no handler for is a refusal to | ||||||
| // report, not a crash: the Api's fail-closed default says exactly which | ||||||
| // operation has no provider, and that sentence is the answer. | ||||||
| try { | ||||||
| const answered = | ||||||
| request.action === "cancel" | ||||||
| ? yield* WorkflowLifecycle.operations.cancel(request.runId) | ||||||
| : yield* WorkflowLifecycle.operations.delete(request.runId); | ||||||
| if (!answered.ok) { | ||||||
| return refuse(answered.error); | ||||||
| } | ||||||
| } catch (error) { | ||||||
| if (error instanceof WorkflowLifecycleProviderError) { | ||||||
| return refuse(error); | ||||||
| } | ||||||
| throw error; | ||||||
| const deleted = yield* WorkflowLifecycle.operations.delete(request.runId); | ||||||
| if (!deleted.ok) { | ||||||
| return refuse(deleted.error); | ||||||
| } | ||||||
| write(`workflow ${request.action}: ${request.runId}`); | ||||||
| // Only what actually went. Nothing here claims to have undone an | ||||||
| // effect the run had on anything outside itself. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant comment β restates what the code does.
Suggested change
| ||||||
| write(`workflow delete: ${request.runId} (${deleted.value.removed.join(", ")})`); | ||||||
| return { exitCode: 0 }; | ||||||
| } | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Redundant comment β restates what the code does.