Class: Airflow::Models::WorkflowRun

Inherits:
Struct
  • Object
show all
Defined in:
lib/async_flow/models.rb

Overview

TODO: Model queues, state, priority?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWorkflowRun

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_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



6
7
8
# File 'lib/async_flow/models.rb', line 6

def created_at
  @created_at
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



6
7
8
# File 'lib/async_flow/models.rb', line 6

def id
  @id
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



6
7
8
# File 'lib/async_flow/models.rb', line 6

def status
  @status
end

#tasksObject

Returns the value of attribute tasks

Returns:

  • (Object)

    the current value of tasks



6
7
8
# File 'lib/async_flow/models.rb', line 6

def tasks
  @tasks
end

#updated_atObject

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



6
7
8
# File 'lib/async_flow/models.rb', line 6

def updated_at
  @updated_at
end

#workflow_idObject

Returns the value of attribute workflow_id

Returns:

  • (Object)

    the current value of workflow_id



6
7
8
# File 'lib/async_flow/models.rb', line 6

def workflow_id
  @workflow_id
end

#workflow_nameObject

Returns the value of attribute workflow_name

Returns:

  • (Object)

    the current value of 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

Returns:

  • (Boolean)


41
42
43
# File 'lib/async_flow/models.rb', line 41

def completed?
  status == "completed"
end

#startObject



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