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.
WARNING: Standalone Activities are experimental.
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.
16 17 18 |
# File 'lib/temporalio/client/activity_handle.rb', line 16 def id @id end |
#result_hint ⇒ Object? (readonly)
Returns Result hint used when deserializing the activity’s result. May be overridden per #result call.
23 24 25 |
# File 'lib/temporalio/client/activity_handle.rb', line 23 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.
19 20 21 |
# File 'lib/temporalio/client/activity_handle.rb', line 19 def run_id @run_id end |
Instance Method Details
#cancel(reason = nil, rpc_options: nil) ⇒ Object
Request cancellation of the activity.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/temporalio/client/activity_handle.rb', line 77 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.
62 63 64 65 66 67 68 69 70 |
# File 'lib/temporalio/client/activity_handle.rb', line 62 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.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/temporalio/client/activity_handle.rb', line 44 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).
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/temporalio/client/activity_handle.rb', line 94 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 |