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_options: nil) ⇒ Object

Complete the activity.

Parameters:

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

    Result of the activity.

  • rpc_options (RPCOptions, nil) (defaults to: nil)

    Advanced RPC options.



43
44
45
46
47
48
49
# File 'lib/temporalio/client/async_activity_handle.rb', line 43

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

#fail(error, last_heartbeat_details: [], rpc_options: 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_options (RPCOptions, nil) (defaults to: nil)

    Advanced RPC options.



56
57
58
59
60
61
62
63
# File 'lib/temporalio/client/async_activity_handle.rb', line 56

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

#heartbeat(*details, rpc_options: nil) ⇒ Object

Record a heartbeat for the activity.

Parameters:

  • details (Array<Object>)

    Details of the heartbeat.

  • rpc_options (RPCOptions, nil) (defaults to: nil)

    Advanced RPC options.



31
32
33
34
35
36
37
# File 'lib/temporalio/client/async_activity_handle.rb', line 31

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

#report_cancellation(*details, rpc_options: nil) ⇒ Object

Report the activity as canceled.

Parameters:

  • details (Array<Object>)

    Cancellation details.

  • rpc_options (RPCOptions, nil) (defaults to: nil)

    Advanced RPC options.

Raises:

  • (AsyncActivityCanceledError)

    If the activity has been canceled.



70
71
72
73
74
75
76
# File 'lib/temporalio/client/async_activity_handle.rb', line 70

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