Class: Airflow::Models::WorkflowRun
- Inherits:
-
Struct
- Object
- Struct
- Airflow::Models::WorkflowRun
- Defined in:
- lib/async_flow/models.rb
Overview
TODO: Model queues, state, priority?
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#workflow_id ⇒ Object
Returns the value of attribute workflow_id.
-
#workflow_name ⇒ Object
Returns the value of attribute workflow_name.
Instance Method Summary collapse
- #complete! ⇒ Object
- #complete_task(task_id, result) ⇒ Object
- #completed? ⇒ Boolean
-
#initialize ⇒ WorkflowRun
constructor
A new instance of WorkflowRun.
- #start ⇒ Object
- #start_task(task_name:, is_workflow_task:) ⇒ Object
Constructor Details
#initialize ⇒ WorkflowRun
Returns a new instance of WorkflowRun.
8 9 10 11 |
# File 'lib/async_flow/models.rb', line 8 def initialize(...) super self.tasks = [] end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def id @id end |
#status ⇒ Object
Returns the value of attribute status
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def status @status end |
#tasks ⇒ Object
Returns the value of attribute tasks
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def tasks @tasks end |
#updated_at ⇒ Object
Returns the value of attribute updated_at
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def updated_at @updated_at end |
#workflow_id ⇒ Object
Returns the value of attribute workflow_id
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def workflow_id @workflow_id end |
#workflow_name ⇒ Object
Returns the value of attribute workflow_name
6 7 8 |
# File 'lib/async_flow/models.rb', line 6 def workflow_name @workflow_name end |
Instance Method Details
#complete! ⇒ Object
37 38 39 |
# File 'lib/async_flow/models.rb', line 37 def complete! self.status = "completed" end |
#complete_task(task_id, result) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/async_flow/models.rb', line 30 def complete_task(task_id, result) task = tasks.find { |t| t.id == task_id } task.complete! task.result = result complete! if tasks.all?(&:completed?) end |
#completed? ⇒ Boolean
41 42 43 |
# File 'lib/async_flow/models.rb', line 41 def completed? status == "completed" end |
#start ⇒ Object
13 14 15 16 |
# File 'lib/async_flow/models.rb', line 13 def start self.status = "started" start_task(task_name: nil, is_workflow_task: true) end |
#start_task(task_name:, is_workflow_task:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/async_flow/models.rb', line 18 def start_task(task_name:, is_workflow_task:) task = Models::Task.new( task_name: task_name, is_workflow_task: is_workflow_task, status: "scheduled", workflow_name: workflow_name, workflow_id: workflow_id ) tasks << task task end |