temporalio 0.4.0-aarch64-linux-musl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +2 -0
- data/Gemfile +27 -0
- data/Rakefile +101 -0
- data/lib/temporalio/activity/complete_async_error.rb +11 -0
- data/lib/temporalio/activity/context.rb +123 -0
- data/lib/temporalio/activity/definition.rb +192 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +12 -0
- data/lib/temporalio/api/activity/v1/message.rb +25 -0
- data/lib/temporalio/api/batch/v1/message.rb +36 -0
- data/lib/temporalio/api/cloud/account/v1/message.rb +28 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +126 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +25 -0
- data/lib/temporalio/api/cloud/cloudservice.rb +3 -0
- data/lib/temporalio/api/cloud/identity/v1/message.rb +41 -0
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +42 -0
- data/lib/temporalio/api/cloud/nexus/v1/message.rb +31 -0
- data/lib/temporalio/api/cloud/operation/v1/message.rb +28 -0
- data/lib/temporalio/api/cloud/region/v1/message.rb +24 -0
- data/lib/temporalio/api/cloud/resource/v1/message.rb +23 -0
- data/lib/temporalio/api/cloud/sink/v1/message.rb +24 -0
- data/lib/temporalio/api/cloud/usage/v1/message.rb +31 -0
- data/lib/temporalio/api/command/v1/message.rb +46 -0
- data/lib/temporalio/api/common/v1/grpc_status.rb +23 -0
- data/lib/temporalio/api/common/v1/message.rb +48 -0
- data/lib/temporalio/api/deployment/v1/message.rb +38 -0
- data/lib/temporalio/api/enums/v1/batch_operation.rb +22 -0
- data/lib/temporalio/api/enums/v1/command_type.rb +21 -0
- data/lib/temporalio/api/enums/v1/common.rb +26 -0
- data/lib/temporalio/api/enums/v1/deployment.rb +23 -0
- data/lib/temporalio/api/enums/v1/event_type.rb +21 -0
- data/lib/temporalio/api/enums/v1/failed_cause.rb +26 -0
- data/lib/temporalio/api/enums/v1/namespace.rb +23 -0
- data/lib/temporalio/api/enums/v1/nexus.rb +21 -0
- data/lib/temporalio/api/enums/v1/query.rb +22 -0
- data/lib/temporalio/api/enums/v1/reset.rb +23 -0
- data/lib/temporalio/api/enums/v1/schedule.rb +21 -0
- data/lib/temporalio/api/enums/v1/task_queue.rb +25 -0
- data/lib/temporalio/api/enums/v1/update.rb +22 -0
- data/lib/temporalio/api/enums/v1/workflow.rb +31 -0
- data/lib/temporalio/api/errordetails/v1/message.rb +44 -0
- data/lib/temporalio/api/export/v1/message.rb +24 -0
- data/lib/temporalio/api/failure/v1/message.rb +37 -0
- data/lib/temporalio/api/filter/v1/message.rb +27 -0
- data/lib/temporalio/api/history/v1/message.rb +92 -0
- data/lib/temporalio/api/namespace/v1/message.rb +31 -0
- data/lib/temporalio/api/nexus/v1/message.rb +41 -0
- data/lib/temporalio/api/operatorservice/v1/request_response.rb +49 -0
- data/lib/temporalio/api/operatorservice/v1/service.rb +23 -0
- data/lib/temporalio/api/operatorservice.rb +3 -0
- data/lib/temporalio/api/payload_visitor.rb +1581 -0
- data/lib/temporalio/api/protocol/v1/message.rb +23 -0
- data/lib/temporalio/api/query/v1/message.rb +28 -0
- data/lib/temporalio/api/replication/v1/message.rb +26 -0
- data/lib/temporalio/api/schedule/v1/message.rb +43 -0
- data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +25 -0
- data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +21 -0
- data/lib/temporalio/api/sdk/v1/user_metadata.rb +23 -0
- data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +23 -0
- data/lib/temporalio/api/taskqueue/v1/message.rb +48 -0
- data/lib/temporalio/api/testservice/v1/request_response.rb +31 -0
- data/lib/temporalio/api/testservice/v1/service.rb +23 -0
- data/lib/temporalio/api/update/v1/message.rb +33 -0
- data/lib/temporalio/api/version/v1/message.rb +26 -0
- data/lib/temporalio/api/workflow/v1/message.rb +51 -0
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +233 -0
- data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
- data/lib/temporalio/api/workflowservice.rb +3 -0
- data/lib/temporalio/api.rb +15 -0
- data/lib/temporalio/cancellation.rb +170 -0
- data/lib/temporalio/client/activity_id_reference.rb +32 -0
- data/lib/temporalio/client/async_activity_handle.rb +85 -0
- data/lib/temporalio/client/connection/cloud_service.rb +726 -0
- data/lib/temporalio/client/connection/operator_service.rb +201 -0
- data/lib/temporalio/client/connection/service.rb +42 -0
- data/lib/temporalio/client/connection/test_service.rb +111 -0
- data/lib/temporalio/client/connection/workflow_service.rb +1251 -0
- data/lib/temporalio/client/connection.rb +316 -0
- data/lib/temporalio/client/interceptor.rb +455 -0
- data/lib/temporalio/client/schedule.rb +991 -0
- data/lib/temporalio/client/schedule_handle.rb +126 -0
- data/lib/temporalio/client/with_start_workflow_operation.rb +115 -0
- data/lib/temporalio/client/workflow_execution.rb +119 -0
- data/lib/temporalio/client/workflow_execution_count.rb +36 -0
- data/lib/temporalio/client/workflow_execution_status.rb +18 -0
- data/lib/temporalio/client/workflow_handle.rb +389 -0
- data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
- data/lib/temporalio/client/workflow_update_handle.rb +65 -0
- data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
- data/lib/temporalio/client.rb +607 -0
- data/lib/temporalio/common_enums.rb +41 -0
- data/lib/temporalio/contrib/open_telemetry.rb +470 -0
- data/lib/temporalio/converters/data_converter.rb +99 -0
- data/lib/temporalio/converters/failure_converter.rb +202 -0
- data/lib/temporalio/converters/payload_codec.rb +26 -0
- data/lib/temporalio/converters/payload_converter/binary_null.rb +34 -0
- data/lib/temporalio/converters/payload_converter/binary_plain.rb +35 -0
- data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +42 -0
- data/lib/temporalio/converters/payload_converter/composite.rb +66 -0
- data/lib/temporalio/converters/payload_converter/encoding.rb +35 -0
- data/lib/temporalio/converters/payload_converter/json_plain.rb +44 -0
- data/lib/temporalio/converters/payload_converter/json_protobuf.rb +41 -0
- data/lib/temporalio/converters/payload_converter.rb +71 -0
- data/lib/temporalio/converters/raw_value.rb +20 -0
- data/lib/temporalio/converters.rb +9 -0
- data/lib/temporalio/error/failure.rb +219 -0
- data/lib/temporalio/error.rb +156 -0
- data/lib/temporalio/internal/bridge/3.2/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/3.3/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/3.4/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +34 -0
- data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +31 -0
- data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +33 -0
- data/lib/temporalio/internal/bridge/api/common/common.rb +27 -0
- data/lib/temporalio/internal/bridge/api/core_interface.rb +40 -0
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
- data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +33 -0
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +56 -0
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +57 -0
- data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +31 -0
- data/lib/temporalio/internal/bridge/api.rb +3 -0
- data/lib/temporalio/internal/bridge/client.rb +95 -0
- data/lib/temporalio/internal/bridge/runtime.rb +56 -0
- data/lib/temporalio/internal/bridge/testing.rb +69 -0
- data/lib/temporalio/internal/bridge/worker.rb +85 -0
- data/lib/temporalio/internal/bridge.rb +36 -0
- data/lib/temporalio/internal/client/implementation.rb +922 -0
- data/lib/temporalio/internal/metric.rb +122 -0
- data/lib/temporalio/internal/proto_utils.rb +165 -0
- data/lib/temporalio/internal/worker/activity_worker.rb +385 -0
- data/lib/temporalio/internal/worker/multi_runner.rb +213 -0
- data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +54 -0
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +383 -0
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +46 -0
- data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +32 -0
- data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +22 -0
- data/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb +25 -0
- data/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb +41 -0
- data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +97 -0
- data/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb +62 -0
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +400 -0
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +37 -0
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb +40 -0
- data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +183 -0
- data/lib/temporalio/internal/worker/workflow_instance.rb +774 -0
- data/lib/temporalio/internal/worker/workflow_worker.rb +239 -0
- data/lib/temporalio/internal.rb +7 -0
- data/lib/temporalio/metric.rb +109 -0
- data/lib/temporalio/retry_policy.rb +74 -0
- data/lib/temporalio/runtime/metric_buffer.rb +94 -0
- data/lib/temporalio/runtime.rb +352 -0
- data/lib/temporalio/scoped_logger.rb +96 -0
- data/lib/temporalio/search_attributes.rb +356 -0
- data/lib/temporalio/testing/activity_environment.rb +160 -0
- data/lib/temporalio/testing/workflow_environment.rb +406 -0
- data/lib/temporalio/testing.rb +10 -0
- data/lib/temporalio/version.rb +5 -0
- data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
- data/lib/temporalio/worker/activity_executor/thread_pool.rb +46 -0
- data/lib/temporalio/worker/activity_executor.rb +55 -0
- data/lib/temporalio/worker/interceptor.rb +365 -0
- data/lib/temporalio/worker/thread_pool.rb +237 -0
- data/lib/temporalio/worker/tuner.rb +189 -0
- data/lib/temporalio/worker/workflow_executor/thread_pool.rb +235 -0
- data/lib/temporalio/worker/workflow_executor.rb +26 -0
- data/lib/temporalio/worker/workflow_replayer.rb +350 -0
- data/lib/temporalio/worker.rb +603 -0
- data/lib/temporalio/workflow/activity_cancellation_type.rb +20 -0
- data/lib/temporalio/workflow/child_workflow_cancellation_type.rb +21 -0
- data/lib/temporalio/workflow/child_workflow_handle.rb +43 -0
- data/lib/temporalio/workflow/definition.rb +598 -0
- data/lib/temporalio/workflow/external_workflow_handle.rb +41 -0
- data/lib/temporalio/workflow/future.rb +151 -0
- data/lib/temporalio/workflow/handler_unfinished_policy.rb +13 -0
- data/lib/temporalio/workflow/info.rb +104 -0
- data/lib/temporalio/workflow/parent_close_policy.rb +19 -0
- data/lib/temporalio/workflow/update_info.rb +20 -0
- data/lib/temporalio/workflow.rb +575 -0
- data/lib/temporalio/workflow_history.rb +47 -0
- data/lib/temporalio.rb +11 -0
- data/temporalio.gemspec +29 -0
- metadata +258 -0
@@ -0,0 +1,170 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/error'
|
4
|
+
require 'temporalio/workflow'
|
5
|
+
|
6
|
+
module Temporalio
|
7
|
+
# Cancellation representation, often known as a "cancellation token". This is used by clients, activities, and
|
8
|
+
# workflows to represent cancellation in a thread/fiber-safe way.
|
9
|
+
class Cancellation
|
10
|
+
# Create a new cancellation.
|
11
|
+
#
|
12
|
+
# This is usually created and destructured into a tuple with the second value being the proc to invoke to cancel.
|
13
|
+
# For example: `cancel, cancel_proc = Temporalio::Cancellation.new`. This is done via {to_ary} which returns a proc
|
14
|
+
# to issue the cancellation in the second value of the array.
|
15
|
+
#
|
16
|
+
# @param parents [Array<Cancellation>] Parent cancellations to link this one to. This cancellation will be canceled
|
17
|
+
# when any parents are canceled.
|
18
|
+
def initialize(*parents)
|
19
|
+
@canceled = false
|
20
|
+
@canceled_reason = nil
|
21
|
+
@canceled_mutex = Mutex.new
|
22
|
+
@canceled_cond_var = nil
|
23
|
+
@cancel_callbacks = {} # Keyed by sentinel value, but value iteration still is deterministic
|
24
|
+
@shield_depth = 0
|
25
|
+
@shield_pending_cancel = nil # When pending, set as single-reason array
|
26
|
+
parents.each { |p| p.add_cancel_callback { on_cancel(reason: p.canceled_reason) } }
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Boolean] Whether this cancellation is canceled.
|
30
|
+
def canceled?
|
31
|
+
@canceled_mutex.synchronize { @canceled }
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [String, nil] Reason for cancellation. Can be nil if not canceled or no reason provided.
|
35
|
+
def canceled_reason
|
36
|
+
@canceled_mutex.synchronize { @canceled_reason }
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Boolean] Whether a cancel is pending but currently shielded.
|
40
|
+
def pending_canceled?
|
41
|
+
@canceled_mutex.synchronize { !@shield_pending_cancel.nil? }
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [String, nil] Reason for pending cancellation. Can be nil if not pending canceled or no reason provided.
|
45
|
+
def pending_canceled_reason
|
46
|
+
@canceled_mutex.synchronize { @shield_pending_cancel&.first }
|
47
|
+
end
|
48
|
+
|
49
|
+
# Raise an error if this cancellation is canceled.
|
50
|
+
#
|
51
|
+
# @param err [Exception] Error to raise.
|
52
|
+
def check!(err = Error::CanceledError.new('Canceled'))
|
53
|
+
raise err if canceled?
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [Array(Cancellation, Proc)] Self and a proc to call to cancel that accepts an optional string `reason`
|
57
|
+
# keyword argument. As a general practice, only the creator of the cancellation should be the one controlling its
|
58
|
+
# cancellation.
|
59
|
+
def to_ary
|
60
|
+
[self, proc { |reason: nil| on_cancel(reason:) }]
|
61
|
+
end
|
62
|
+
|
63
|
+
# Wait on this to be canceled. This is backed by a {::ConditionVariable} outside of workflows or
|
64
|
+
# {Workflow.wait_condition} inside of workflows.
|
65
|
+
def wait
|
66
|
+
# If this is in a workflow, just wait for the canceled. This is because ConditionVariable does a no-duration
|
67
|
+
# kernel_sleep to the fiber scheduler which ends up recursing back into this because the workflow implementation
|
68
|
+
# of kernel_sleep by default relies on cancellation.
|
69
|
+
if Workflow.in_workflow?
|
70
|
+
Workflow.wait_condition(cancellation: nil) { @canceled }
|
71
|
+
return
|
72
|
+
end
|
73
|
+
|
74
|
+
@canceled_mutex.synchronize do
|
75
|
+
break if @canceled
|
76
|
+
|
77
|
+
# Add cond var if not present
|
78
|
+
if @canceled_cond_var.nil?
|
79
|
+
@canceled_cond_var = ConditionVariable.new
|
80
|
+
@cancel_callbacks[Object.new] = proc { @canceled_mutex.synchronize { @canceled_cond_var.broadcast } }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Wait on it
|
84
|
+
@canceled_cond_var.wait(@canceled_mutex)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Shield the given block from cancellation. This means any cancellation that occurs while shielded code is running
|
89
|
+
# will be set as "pending" and will not take effect until after the block completes. If shield calls are nested, the
|
90
|
+
# cancellation remains "pending" until the last shielded block ends.
|
91
|
+
#
|
92
|
+
# @yield Requires a block to run under shield.
|
93
|
+
# @return [Object] Result of the block.
|
94
|
+
def shield
|
95
|
+
raise ArgumentError, 'Block required' unless block_given?
|
96
|
+
|
97
|
+
@canceled_mutex.synchronize { @shield_depth += 1 }
|
98
|
+
yield
|
99
|
+
ensure
|
100
|
+
callbacks_to_run = @canceled_mutex.synchronize do
|
101
|
+
@shield_depth -= 1
|
102
|
+
if @shield_depth.zero? && @shield_pending_cancel
|
103
|
+
reason = @shield_pending_cancel.first
|
104
|
+
@shield_pending_cancel = nil
|
105
|
+
prepare_cancel(reason:)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
callbacks_to_run&.each(&:call)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Advanced call to invoke a proc or block on cancel. The callback usually needs to be quick and thread-safe since it
|
112
|
+
# is called in the canceler's thread. Usually the callback will just be something like pushing on a queue or
|
113
|
+
# signaling a condition variable. If the cancellation is already canceled, the callback is called inline before
|
114
|
+
# returning.
|
115
|
+
#
|
116
|
+
# @note WARNING: This is advanced API, users should use {wait} or similar.
|
117
|
+
#
|
118
|
+
# @yield Accepts block if not using `proc`.
|
119
|
+
# @return [Object] Key that can be used with {remove_cancel_callback} or `nil`` if run immediately.
|
120
|
+
def add_cancel_callback(&block)
|
121
|
+
raise ArgumentError, 'Must provide block' unless block_given?
|
122
|
+
|
123
|
+
callback_to_run_immediately, key = @canceled_mutex.synchronize do
|
124
|
+
break [block, nil] if @canceled
|
125
|
+
|
126
|
+
key = Object.new
|
127
|
+
@cancel_callbacks[key] = block
|
128
|
+
[nil, key]
|
129
|
+
end
|
130
|
+
callback_to_run_immediately&.call
|
131
|
+
key
|
132
|
+
end
|
133
|
+
|
134
|
+
# Remove a cancel callback using the key returned from {add_cancel_callback}.
|
135
|
+
#
|
136
|
+
# @param key [Object] Key returned from {add_cancel_callback}.
|
137
|
+
def remove_cancel_callback(key)
|
138
|
+
@canceled_mutex.synchronize do
|
139
|
+
@cancel_callbacks.delete(key)
|
140
|
+
end
|
141
|
+
nil
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def on_cancel(reason:)
|
147
|
+
callbacks_to_run = @canceled_mutex.synchronize do
|
148
|
+
# If we're shielding, set as pending and return nil
|
149
|
+
if @shield_depth.positive?
|
150
|
+
@shield_pending_cancel = [reason]
|
151
|
+
nil
|
152
|
+
else
|
153
|
+
prepare_cancel(reason:)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
callbacks_to_run&.each(&:call)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Expects to be called inside mutex by caller, returns callbacks to run
|
160
|
+
def prepare_cancel(reason:)
|
161
|
+
return nil if @canceled
|
162
|
+
|
163
|
+
@canceled = true
|
164
|
+
@canceled_reason = reason
|
165
|
+
to_return = @cancel_callbacks.dup
|
166
|
+
@cancel_callbacks.clear
|
167
|
+
to_return.values
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/api'
|
4
|
+
require 'temporalio/client/interceptor'
|
5
|
+
require 'temporalio/error'
|
6
|
+
|
7
|
+
module Temporalio
|
8
|
+
class Client
|
9
|
+
# Reference to an existing activity by its workflow ID, run ID, and activity ID.
|
10
|
+
class ActivityIDReference
|
11
|
+
# @return [String] ID for the workflow.
|
12
|
+
attr_reader :workflow_id
|
13
|
+
|
14
|
+
# @return [String, nil] Run ID for the workflow.
|
15
|
+
attr_reader :run_id
|
16
|
+
|
17
|
+
# @return [String] ID for the activity.
|
18
|
+
attr_reader :activity_id
|
19
|
+
|
20
|
+
# Create an activity ID reference.
|
21
|
+
#
|
22
|
+
# @param workflow_id [String] ID for the workflow.
|
23
|
+
# @param run_id [String, nil] Run ID for the workflow.
|
24
|
+
# @param activity_id [String] ID for the workflow.
|
25
|
+
def initialize(workflow_id:, run_id:, activity_id:)
|
26
|
+
@workflow_id = workflow_id
|
27
|
+
@run_id = run_id
|
28
|
+
@activity_id = activity_id
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/api'
|
4
|
+
require 'temporalio/client/activity_id_reference'
|
5
|
+
require 'temporalio/client/interceptor'
|
6
|
+
require 'temporalio/error'
|
7
|
+
|
8
|
+
module Temporalio
|
9
|
+
class Client
|
10
|
+
# Handle representing an external activity for completion and heartbeat. This is usually created via
|
11
|
+
# {Client.async_activity_handle}.
|
12
|
+
class AsyncActivityHandle
|
13
|
+
# @return [String, nil] Task token if created with a task token. Mutually exclusive with {id_reference}.
|
14
|
+
attr_reader :task_token
|
15
|
+
|
16
|
+
# @return [ActivityIDReference, nil] Activity ID reference if created with one. Mutually exclusive with
|
17
|
+
# {task_token}.
|
18
|
+
attr_reader :id_reference
|
19
|
+
|
20
|
+
# @!visibility private
|
21
|
+
def initialize(client:, task_token:, id_reference:)
|
22
|
+
@client = client
|
23
|
+
@task_token = task_token
|
24
|
+
@id_reference = id_reference
|
25
|
+
end
|
26
|
+
|
27
|
+
# Record a heartbeat for the activity.
|
28
|
+
#
|
29
|
+
# @param details [Array<Object>] Details of the heartbeat.
|
30
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
31
|
+
def heartbeat(*details, rpc_options: nil)
|
32
|
+
@client._impl.heartbeat_async_activity(Interceptor::HeartbeatAsyncActivityInput.new(
|
33
|
+
task_token_or_id_reference:,
|
34
|
+
details:,
|
35
|
+
rpc_options:
|
36
|
+
))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Complete the activity.
|
40
|
+
#
|
41
|
+
# @param result [Object, nil] Result of the activity.
|
42
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
43
|
+
def complete(result = nil, rpc_options: nil)
|
44
|
+
@client._impl.complete_async_activity(Interceptor::CompleteAsyncActivityInput.new(
|
45
|
+
task_token_or_id_reference:,
|
46
|
+
result:,
|
47
|
+
rpc_options:
|
48
|
+
))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Fail the activity.
|
52
|
+
#
|
53
|
+
# @param error [Exception] Error for the activity.
|
54
|
+
# @param last_heartbeat_details [Array<Object>] Last heartbeat details for the activity.
|
55
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
56
|
+
def fail(error, last_heartbeat_details: [], rpc_options: nil)
|
57
|
+
@client._impl.fail_async_activity(Interceptor::FailAsyncActivityInput.new(
|
58
|
+
task_token_or_id_reference:,
|
59
|
+
error:,
|
60
|
+
last_heartbeat_details:,
|
61
|
+
rpc_options:
|
62
|
+
))
|
63
|
+
end
|
64
|
+
|
65
|
+
# Report the activity as canceled.
|
66
|
+
#
|
67
|
+
# @param details [Array<Object>] Cancellation details.
|
68
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
69
|
+
# @raise [AsyncActivityCanceledError] If the activity has been canceled.
|
70
|
+
def report_cancellation(*details, rpc_options: nil)
|
71
|
+
@client._impl.report_cancellation_async_activity(Interceptor::ReportCancellationAsyncActivityInput.new(
|
72
|
+
task_token_or_id_reference:,
|
73
|
+
details:,
|
74
|
+
rpc_options:
|
75
|
+
))
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def task_token_or_id_reference
|
81
|
+
@task_token || @id_reference or raise
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|