Skip to content

Commit

Permalink
Add delete alarm
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Nov 3, 2023
1 parent d137270 commit b71ce19
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const buildRoutes = (wkflow: Workflow): Routes => {
"POST": async (req: Request) => {
const body: WorkflowExecution = await req.json();
const shouldRestart = new URL(req.url).searchParams.has("restart");
const deleteAlarmPromise = shouldRestart
? wkflow.state.storage.deleteAlarm()
: Promise.resolve();
const pendingAndHistory = shouldRestart
? Promise.all([
wkflow.execution.pending.get(),
Expand All @@ -48,6 +51,7 @@ export const buildRoutes = (wkflow: Workflow): Routes => {
wkflow.execution.pending.del(...pending),
wkflow.execution.history.del(...history),
createPromise,
deleteAlarmPromise,
]);
wkflow.workflowExecution = body;
return new Response(JSON.stringify(body), { status: 201 });
Expand Down

0 comments on commit b71ce19

Please sign in to comment.