Class: Temporalio::Client::ActivityHandle
- Inherits:
-
Object
- Object
- Temporalio::Client::ActivityHandle
- Defined in:
- lib/temporalio/client/activity_handle.rb
Overview
Handle for interacting with a standalone activity. Usually created via #activity_handle or #start_activity.
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
ID for the activity.
-
#result_hint ⇒ Object?
readonly
Result hint used when deserializing the activity's result.
-
#run_id ⇒ String?
readonly
Run ID for this activity execution.
Instance Method Summary collapse
-
#cancel(reason = nil, rpc_options: nil) ⇒ Object
Request cancellation of the activity.
-
#describe(rpc_options: nil) ⇒ ActivityExecution::Description
Describe the activity.
-
#result(result_hint: nil, rpc_options: nil) ⇒ Object?
Wait for the activity's outcome (result or failure).
-
#terminate(reason = nil, rpc_options: nil) ⇒ Object
Terminate the activity (force-close).
Instance Attribute Details
#id ⇒ String (readonly)
Returns ID for the activity.
14 15 16 |
# File 'lib/temporalio/client/activity_handle.rb', line 14 def id @id end |
#result_hint ⇒ Object? (readonly)
Returns Result hint used when deserializing the activity's result. May be overridden per #result call.
21 22 23 |
# File 'lib/temporalio/client/activity_handle.rb', line 21 def result_hint @result_hint end |
#run_id ⇒ String? (readonly)
Returns Run ID for this activity execution. When nil, this handle targets the latest run.
17 18 19 |
# File 'lib/temporalio/client/activity_handle.rb', line 17 def run_id @run_id end |
Instance Method Details
#cancel(reason = nil, rpc_options: nil) ⇒ Object
Request cancellation of the activity.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/temporalio/client/activity_handle.rb', line 75 def cancel(reason = nil, rpc_options: nil) @client._impl.cancel_activity( Interceptor::CancelActivityInput.new( activity_id: id, activity_run_id: run_id, reason:, rpc_options: ) ) nil end |
#describe(rpc_options: nil) ⇒ ActivityExecution::Description
Describe the activity.
60 61 62 63 64 65 66 67 68 |
# File 'lib/temporalio/client/activity_handle.rb', line 60 def describe(rpc_options: nil) @client._impl.describe_activity( Interceptor::DescribeActivityInput.new( activity_id: id, activity_run_id: run_id, rpc_options: ) ) end |
#result(result_hint: nil, rpc_options: nil) ⇒ Object?
Wait for the activity's outcome (result or failure). Internally long-polls PollActivityExecution and reissues until the activity reaches a terminal state, so this can block indefinitely for long-running activities.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/temporalio/client/activity_handle.rb', line 42 def result(result_hint: nil, rpc_options: nil) hint = result_hint || @result_hint outcome = @client._impl.fetch_activity_outcome( Interceptor::FetchActivityOutcomeInput.new( activity_id: id, activity_run_id: run_id, rpc_options: ) ) _process_outcome(outcome, hint) end |
#terminate(reason = nil, rpc_options: nil) ⇒ Object
Terminate the activity (force-close).
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/temporalio/client/activity_handle.rb', line 92 def terminate(reason = nil, rpc_options: nil) @client._impl.terminate_activity( Interceptor::TerminateActivityInput.new( activity_id: id, activity_run_id: run_id, reason:, rpc_options: ) ) nil end |