Class: Temporalio::Client::WorkflowUpdateHandle

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/client/workflow_update_handle.rb

Overview

Handle for a workflow update execution request. This is usually created via Temporalio::Client::WorkflowHandle#start_update or Temporalio::Client::WorkflowHandle#update_handle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idString (readonly)

Returns ID for the workflow update.

Returns:

  • (String)

    ID for the workflow update.



13
14
15
# File 'lib/temporalio/client/workflow_update_handle.rb', line 13

def id
  @id
end

#workflow_idString (readonly)

Returns ID for the workflow.

Returns:

  • (String)

    ID for the workflow.



16
17
18
# File 'lib/temporalio/client/workflow_update_handle.rb', line 16

def workflow_id
  @workflow_id
end

#workflow_run_idString? (readonly)

Returns Run ID for the workflow.

Returns:

  • (String, nil)

    Run ID for the workflow.



19
20
21
# File 'lib/temporalio/client/workflow_update_handle.rb', line 19

def workflow_run_id
  @workflow_run_id
end

Instance Method Details

#result(rpc_metadata: nil, rpc_timeout: nil) ⇒ Object?

Wait for and return the result of the update. The result may already be known in which case no network call is made. Otherwise the result will be polled for until it is returned.

Parameters:

  • rpc_metadata (Hash<String, String>, nil) (defaults to: nil)

    Headers to include on the RPC call.

  • rpc_timeout (Float, nil) (defaults to: nil)

    Number of seconds before timeout.

Returns:

  • (Object, nil)

    Update result.

Raises:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/temporalio/client/workflow_update_handle.rb', line 48

def result(rpc_metadata: nil, rpc_timeout: nil)
  @known_outcome ||= @client._impl.poll_workflow_update(Interceptor::PollWorkflowUpdateInput.new(
                                                          workflow_id:,
                                                          run_id: workflow_run_id,
                                                          update_id: id,
                                                          rpc_metadata:,
                                                          rpc_timeout:
                                                        ))

  if @known_outcome.failure
    raise Error::WorkflowUpdateFailedError.new, cause: @client.data_converter.from_failure(@known_outcome.failure)
  end

  results = @client.data_converter.from_payloads(@known_outcome.success)
  warn("Expected 0 or 1 update result, got #{results.size}") if results.size > 1
  results.first
end

#result_obtained?Boolean

Returns True if the result is already known and #result will not make a blocking call, false if #result will make a blocking call because the result is not yet known.

Returns:

  • (Boolean)

    True if the result is already known and #result will not make a blocking call, false if #result will make a blocking call because the result is not yet known.



32
33
34
# File 'lib/temporalio/client/workflow_update_handle.rb', line 32

def result_obtained?
  !@known_outcome.nil?
end