Class: Temporalio::Internal::Worker::WorkflowInstance::ChildWorkflowHandle

Inherits:
Workflow::ChildWorkflowHandle show all
Defined in:
lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb

Overview

Implementation of the child workflow handle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, first_execution_run_id:, instance:, cancellation:, cancel_callback_key:) ⇒ ChildWorkflowHandle

rubocop:disable Lint/MissingSuper



15
16
17
18
19
20
21
22
# File 'lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb', line 15

def initialize(id:, first_execution_run_id:, instance:, cancellation:, cancel_callback_key:) # rubocop:disable Lint/MissingSuper
  @id = id
  @first_execution_run_id = first_execution_run_id
  @instance = instance
  @cancellation = cancellation
  @cancel_callback_key = cancel_callback_key
  @resolution = nil
end

Instance Attribute Details

#first_execution_run_idObject (readonly)

Returns the value of attribute first_execution_run_id.



13
14
15
# File 'lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb', line 13

def first_execution_run_id
  @first_execution_run_id
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb', line 13

def id
  @id
end

Instance Method Details

#_resolve(resolution) ⇒ Object



42
43
44
45
# File 'lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb', line 42

def _resolve(resolution)
  @cancellation.remove_cancel_callback(@cancel_callback_key)
  @resolution = resolution
end

#resultObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb', line 24

def result
  # Notice that we actually provide a detached cancellation here instead of defaulting to workflow
  # cancellation because we don't want workflow cancellation (or a user-provided cancellation to this result
  # call) to be able to interrupt waiting on a child that may be processing the cancellation.
  Workflow.wait_condition(cancellation: Cancellation.new) { @resolution }

  case @resolution.status
  when :completed
    @instance.payload_converter.from_payload(@resolution.completed.result)
  when :failed
    raise @instance.failure_converter.from_failure(@resolution.failed.failure, @instance.payload_converter)
  when :cancelled
    raise @instance.failure_converter.from_failure(@resolution.cancelled.failure, @instance.payload_converter)
  else
    raise "Unrecognized resolution status: #{@resolution.status}"
  end
end

#signal(signal, *args, cancellation: Workflow.cancellation) ⇒ Object



47
48
49
# File 'lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb', line 47

def signal(signal, *args, cancellation: Workflow.cancellation)
  @instance.context._signal_child_workflow(id:, signal:, args:, cancellation:)
end