Class: Temporalio::Client::AsyncActivityHandle

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

Overview

Handle representing an external activity for completion and heartbeat. This is usually created via #async_activity_handle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#id_referenceActivityIDReference? (readonly)

Returns:

  • (ActivityIDReference, nil)

    Activity ID reference if created with one. Mutually exclusive with



18
19
20
# File 'lib/temporalio/client/async_activity_handle.rb', line 18

def id_reference
  @id_reference
end

#task_tokenString? (readonly)

Returns Task token if created with a task token. Mutually exclusive with #id_reference.

Returns:

  • (String, nil)

    Task token if created with a task token. Mutually exclusive with #id_reference.



14
15
16
# File 'lib/temporalio/client/async_activity_handle.rb', line 14

def task_token
  @task_token
end

Instance Method Details

#complete(result = nil, rpc_metadata: nil, rpc_timeout: nil) ⇒ Object

Complete the activity.

Parameters:

  • result (Object, nil) (defaults to: nil)

    Result of the activity.

  • 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.



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/temporalio/client/async_activity_handle.rb', line 50

def complete(
  result = nil,
  rpc_metadata: nil,
  rpc_timeout: nil
)
  @client._impl.complete_async_activity(Interceptor::CompleteAsyncActivityInput.new(
                                          task_token_or_id_reference:,
                                          result:,
                                          rpc_metadata:,
                                          rpc_timeout:
                                        ))
end

#fail(error, last_heartbeat_details: [], rpc_metadata: nil, rpc_timeout: nil) ⇒ Object

Fail the activity.

Parameters:

  • error (Exception)

    Error for the activity.

  • last_heartbeat_details (Array<Object>) (defaults to: [])

    Last heartbeat details for the activity.

  • 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.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/temporalio/client/async_activity_handle.rb', line 69

def fail(
  error,
  last_heartbeat_details: [],
  rpc_metadata: nil,
  rpc_timeout: nil
)
  @client._impl.fail_async_activity(Interceptor::FailAsyncActivityInput.new(
                                      task_token_or_id_reference:,
                                      error:,
                                      last_heartbeat_details:,
                                      rpc_metadata:,
                                      rpc_timeout:
                                    ))
end

#heartbeat(*details, rpc_metadata: nil, rpc_timeout: nil) ⇒ Object

Record a heartbeat for the activity.

Parameters:

  • details (Array<Object>)

    Details of the heartbeat.

  • 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.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/temporalio/client/async_activity_handle.rb', line 32

def heartbeat(
  *details,
  rpc_metadata: nil,
  rpc_timeout: nil
)
  @client._impl.heartbeat_async_activity(Interceptor::HeartbeatAsyncActivityInput.new(
                                           task_token_or_id_reference:,
                                           details:,
                                           rpc_metadata:,
                                           rpc_timeout:
                                         ))
end

#report_cancellation(*details, rpc_metadata: nil, rpc_timeout: nil) ⇒ Object

Report the activity as canceled.

Parameters:

  • details (Array<Object>)

    Cancellation details.

  • 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.

Raises:

  • (AsyncActivityCanceledError)

    If the activity has been canceled.



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/temporalio/client/async_activity_handle.rb', line 90

def report_cancellation(
  *details,
  rpc_metadata: nil,
  rpc_timeout: nil
)
  @client._impl.report_cancellation_async_activity(Interceptor::ReportCancellationAsyncActivityInput.new(
                                                     task_token_or_id_reference:,
                                                     details:,
                                                     rpc_metadata:,
                                                     rpc_timeout:
                                                   ))
end