Class: Hatchet::WorkflowRunRef

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/workflow_run.rb

Overview

Reference to a running workflow, returned by ‘Workflow#run_no_wait`

The result is the full workflow-level output keyed by task readable_id, e.g. ‘=> {…, “step2” => …}`.

Examples:

Get result from a run reference

ref = workflow.run_no_wait(input)
result = ref.result  # blocks until complete

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_run_id:, client: nil, listener: nil) ⇒ WorkflowRunRef

Returns a new instance of WorkflowRunRef.

Parameters:

  • workflow_run_id (String)

    The workflow run ID

  • client (Hatchet::Client) (defaults to: nil)

    The Hatchet client (used as fallback)

  • listener (Hatchet::WorkflowRunListener, nil) (defaults to: nil)

    Pooled gRPC listener



21
22
23
24
25
26
27
# File 'lib/hatchet/workflow_run.rb', line 21

def initialize(workflow_run_id:, client: nil, listener: nil)
  @workflow_run_id = workflow_run_id
  @client = client
  @listener = listener
  @result = nil
  @resolved = false
end

Instance Attribute Details

#workflow_run_idString (readonly)

Returns The workflow run ID.

Returns:

  • (String)

    The workflow run ID



16
17
18
# File 'lib/hatchet/workflow_run.rb', line 16

def workflow_run_id
  @workflow_run_id
end

Instance Method Details

#resultHash

Block until the workflow run completes and return the result.

Uses the pooled gRPC ‘SubscribeToWorkflowRuns` listener when available. Falls back to gRPC `GetRunDetails` polling otherwise.

Returns:

  • (Hash)

    The workflow run output keyed by task readable_id

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hatchet/workflow_run.rb', line 37

def result
  return @result if @resolved

  @result = if @listener
              @listener.result(@workflow_run_id)
            else
              poll_result_via_grpc
            end

  @resolved = true
  @result
end