-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENHC0010012A] Workflow executions: Cleanup job + service code flow (#…
…581) * main code flow for cleanup queuing * fix codeflow for canceled and status jobs * improve code flow with switch case * fix codeflow to unreachable case * fix existing test cases * add destroy service tests * simplify code * fix tests
- Loading branch information
1 parent
4d1aa01
commit 52a179c
Showing
33 changed files
with
896 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
# cleans up workflow execution files no longer needed after completion | ||
class WorkflowExecutionCleanupJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(workflow_execution) | ||
return unless workflow_execution.completed? || | ||
workflow_execution.canceled? || | ||
workflow_execution.error? | ||
|
||
WorkflowExecutions::CleanupService.new(workflow_execution).execute | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
209 changes: 209 additions & 0 deletions
209
docs-site/docs/development/integration/workflow_execution_code_flow.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
--- | ||
sidebar_position: 2 | ||
id: workflow_execution_code_flow | ||
title: Workflow Execution Code Flow Diagram | ||
--- | ||
|
||
![my image](/img/workflow_execution_code2flow.png) | ||
|
||
### code2flow.com code | ||
|
||
``` | ||
switch (User Interactions) { | ||
Create a new run => { | ||
goto new_run; | ||
} | ||
Cancel running workflow =>{ | ||
`canceling` **State**; | ||
goto cancel_run; | ||
} | ||
Destroy existing workflow => { | ||
goto destroy; | ||
} | ||
} | ||
new_run: | ||
block { | ||
`WorkflowExecutions\::CreateService`; | ||
`initial` **State**; | ||
} | ||
block { | ||
switch(**WorkflowExecutionPreparationJob**){ | ||
User Interrupt: Cancel => { | ||
Job aborted; | ||
goto cancel_run; | ||
} | ||
Normal execution => { | ||
} | ||
} | ||
`WorkflowExecutions\::PreparationService`; | ||
`prepared` **State** | ||
Queue submission job; | ||
} | ||
block { | ||
wesj: { | ||
switch( **WorkflowExecutionSubmissionJob**) { | ||
Normal Execution => { | ||
goto wesus; | ||
} | ||
User Interrupt: Cancel => { | ||
Job aborted; | ||
goto cancel_run; | ||
} | ||
Connection Error =>{ | ||
goto wesj; | ||
} | ||
} | ||
} | ||
wesus: { | ||
switch ( `WorkflowExecutions::SubmissionService`) { | ||
ApiExceptionError => { | ||
`error` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
Normal execution => { | ||
`submitted` **State** | ||
Queue status job; | ||
goto westj; | ||
} | ||
} | ||
} | ||
} | ||
block{ | ||
westj: { | ||
switch( **WorkflowExecutionStatusJob**) { | ||
Normal execution => { | ||
goto wests; | ||
} | ||
User Interrupt: Cancel => { | ||
Job aborted; | ||
goto cancel_run; | ||
} | ||
Connection Error =>{ | ||
goto westj; | ||
} | ||
} | ||
} | ||
wests: { | ||
switch (`WorkflowExecutions::StatusService`) { | ||
ApiExceptionError => { | ||
`error` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
Ga4gh `running` => { | ||
Queue job again; | ||
goto westj; | ||
} | ||
Ga4gh `error` / `canceled` => { | ||
`error` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
Ga4gh `completed` => { | ||
`completing` **State** | ||
Queue completion job; | ||
goto wecj; | ||
} | ||
} | ||
} | ||
} | ||
block { | ||
wecj:{ | ||
**WorkflowExecutionCompletionJob** | ||
} | ||
wecs: { | ||
switch ( `WorkflowExecutions::CompletionService`) { | ||
Normal execution => { | ||
`completed` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
} | ||
} | ||
} | ||
block { | ||
cancel_run: { | ||
switch(`WorkflowExecutions::CancelService`){ | ||
`initial` / `prepared` **States** => { | ||
`canceled` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
all other **States** => { | ||
`canceling` **State** | ||
Queue cancelation job; | ||
goto cancelation; | ||
} | ||
} | ||
} | ||
} | ||
block { | ||
cancelation: { | ||
switch (**WorkflowExecutionCancelationJob**) { | ||
ApiExceptionError=>{ | ||
switch(Run state?){ | ||
Already completed=>{ | ||
`canceled` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
Actual error=>{ | ||
`error` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
} | ||
return; | ||
} | ||
Connection Error => { | ||
goto cancelation; | ||
} | ||
Normal execution => { | ||
} | ||
} | ||
`WorkflowExecutions\::CancelationService`; | ||
`canceled` **State** | ||
Queue cleanup job; | ||
goto cleanup_job; | ||
} | ||
} | ||
block { | ||
destroy: { | ||
`WorkflowExecutions\::DestroyService`; | ||
switch(Check if workflow execution can be destroyed){ | ||
Check if cleaned => { | ||
goto cleaned; | ||
} | ||
} | ||
return; | ||
} | ||
} | ||
block { | ||
cleanup_job:{ | ||
**WorkflowExecutionCleanupJob**; | ||
`WorkflowExecutions\::CleanupService`; | ||
Sets `cleaned` to `true` | ||
} | ||
} | ||
block { | ||
cleaned: | ||
`workflow_execution.cleaned? | ||
} | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Oops, something went wrong.