Class: Hatchet::TaskRunRef
- Inherits:
-
Object
- Object
- Hatchet::TaskRunRef
- Defined in:
- lib/hatchet/workflow_run.rb
Overview
Reference to a running standalone task, returned by ‘Task#run_no_wait`.
Wraps a WorkflowRunRef and automatically extracts the task-specific output from the workflow-level result. For a task named “my_task”, calling result returns the task output directly (e.g. ‘=> 42`) instead of the full keyed output (`=> {“value” => 42}`).
Instance Attribute Summary collapse
-
#workflow_run_id ⇒ String
readonly
The workflow run ID.
Instance Method Summary collapse
-
#initialize(workflow_run_ref:, task_name:) ⇒ TaskRunRef
constructor
A new instance of TaskRunRef.
-
#result ⇒ Hash
Block until the task completes and return the extracted task output.
Constructor Details
#initialize(workflow_run_ref:, task_name:) ⇒ TaskRunRef
Returns a new instance of TaskRunRef.
112 113 114 115 116 |
# File 'lib/hatchet/workflow_run.rb', line 112 def initialize(workflow_run_ref:, task_name:) @workflow_run_ref = workflow_run_ref @task_name = task_name.to_s @workflow_run_id = workflow_run_ref.workflow_run_id end |
Instance Attribute Details
#workflow_run_id ⇒ String (readonly)
Returns The workflow run ID.
108 109 110 |
# File 'lib/hatchet/workflow_run.rb', line 108 def workflow_run_id @workflow_run_id end |
Instance Method Details
#result ⇒ Hash
Block until the task completes and return the extracted task output
122 123 124 125 126 127 |
# File 'lib/hatchet/workflow_run.rb', line 122 def result full_result = @workflow_run_ref.result return full_result unless full_result.is_a?(Hash) full_result[@task_name] || full_result end |