temporalio 0.3.0 → 0.5.0
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 +4 -4
- data/.yardopts +1 -1
- data/Cargo.lock +1019 -669
- data/Cargo.toml +5 -5
- data/Gemfile +4 -0
- data/README.md +281 -44
- data/Rakefile +1 -1
- data/ext/Cargo.toml +4 -3
- data/lib/temporalio/activity/cancellation_details.rb +58 -0
- data/lib/temporalio/activity/context.rb +23 -1
- data/lib/temporalio/activity/definition.rb +63 -8
- data/lib/temporalio/activity/info.rb +28 -4
- data/lib/temporalio/activity.rb +2 -0
- data/lib/temporalio/api/activity/v1/message.rb +1 -1
- data/lib/temporalio/api/batch/v1/message.rb +9 -2
- data/lib/temporalio/api/cloud/account/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +11 -2
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +2 -2
- data/lib/temporalio/api/cloud/identity/v1/message.rb +7 -2
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +6 -2
- data/lib/temporalio/api/cloud/nexus/v1/message.rb +3 -2
- data/lib/temporalio/api/cloud/operation/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/region/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/resource/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/sink/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/usage/v1/message.rb +1 -1
- data/lib/temporalio/api/command/v1/message.rb +2 -2
- data/lib/temporalio/api/common/v1/grpc_status.rb +1 -1
- data/lib/temporalio/api/common/v1/message.rb +4 -2
- data/lib/temporalio/api/deployment/v1/message.rb +39 -0
- data/lib/temporalio/api/enums/v1/batch_operation.rb +2 -2
- data/lib/temporalio/api/enums/v1/command_type.rb +1 -1
- data/lib/temporalio/api/enums/v1/common.rb +5 -2
- data/lib/temporalio/api/enums/v1/deployment.rb +24 -0
- data/lib/temporalio/api/enums/v1/event_type.rb +2 -2
- data/lib/temporalio/api/enums/v1/failed_cause.rb +2 -2
- data/lib/temporalio/api/enums/v1/namespace.rb +1 -1
- data/lib/temporalio/api/enums/v1/nexus.rb +21 -0
- data/lib/temporalio/api/enums/v1/query.rb +1 -1
- data/lib/temporalio/api/enums/v1/reset.rb +2 -2
- data/lib/temporalio/api/enums/v1/schedule.rb +1 -1
- data/lib/temporalio/api/enums/v1/task_queue.rb +1 -1
- data/lib/temporalio/api/enums/v1/update.rb +1 -1
- data/lib/temporalio/api/enums/v1/workflow.rb +3 -2
- data/lib/temporalio/api/errordetails/v1/message.rb +4 -2
- data/lib/temporalio/api/export/v1/message.rb +1 -1
- data/lib/temporalio/api/failure/v1/message.rb +5 -2
- data/lib/temporalio/api/filter/v1/message.rb +1 -1
- data/lib/temporalio/api/history/v1/message.rb +6 -2
- data/lib/temporalio/api/namespace/v1/message.rb +1 -1
- data/lib/temporalio/api/nexus/v1/message.rb +3 -2
- data/lib/temporalio/api/operatorservice/v1/request_response.rb +1 -1
- data/lib/temporalio/api/operatorservice/v1/service.rb +1 -1
- data/lib/temporalio/api/payload_visitor.rb +162 -7
- data/lib/temporalio/api/protocol/v1/message.rb +1 -1
- data/lib/temporalio/api/query/v1/message.rb +3 -2
- data/lib/temporalio/api/replication/v1/message.rb +1 -1
- data/lib/temporalio/api/rules/v1/message.rb +27 -0
- data/lib/temporalio/api/schedule/v1/message.rb +2 -2
- data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +1 -1
- data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +1 -1
- data/lib/temporalio/api/sdk/v1/user_metadata.rb +1 -1
- data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +1 -1
- data/lib/temporalio/api/taskqueue/v1/message.rb +5 -2
- data/lib/temporalio/api/testservice/v1/request_response.rb +1 -1
- data/lib/temporalio/api/testservice/v1/service.rb +1 -1
- data/lib/temporalio/api/update/v1/message.rb +1 -1
- data/lib/temporalio/api/version/v1/message.rb +1 -1
- data/lib/temporalio/api/worker/v1/message.rb +30 -0
- data/lib/temporalio/api/workflow/v1/message.rb +22 -2
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +58 -12
- data/lib/temporalio/api/workflowservice/v1/service.rb +2 -2
- data/lib/temporalio/api.rb +1 -0
- data/lib/temporalio/client/async_activity_handle.rb +12 -4
- data/lib/temporalio/client/connection/cloud_service.rb +60 -0
- data/lib/temporalio/client/connection/workflow_service.rb +343 -28
- data/lib/temporalio/client/interceptor.rb +64 -7
- data/lib/temporalio/client/schedule.rb +35 -3
- data/lib/temporalio/client/with_start_workflow_operation.rb +123 -0
- data/lib/temporalio/client/workflow_execution.rb +19 -0
- data/lib/temporalio/client/workflow_handle.rb +47 -7
- data/lib/temporalio/client/workflow_update_handle.rb +9 -3
- data/lib/temporalio/client.rb +231 -4
- data/lib/temporalio/common_enums.rb +14 -0
- data/lib/temporalio/contrib/open_telemetry.rb +474 -0
- data/lib/temporalio/converters/data_converter.rb +18 -8
- data/lib/temporalio/converters/failure_converter.rb +6 -3
- data/lib/temporalio/converters/payload_converter/binary_null.rb +2 -2
- data/lib/temporalio/converters/payload_converter/binary_plain.rb +2 -2
- data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +2 -2
- data/lib/temporalio/converters/payload_converter/composite.rb +6 -4
- data/lib/temporalio/converters/payload_converter/encoding.rb +4 -2
- data/lib/temporalio/converters/payload_converter/json_plain.rb +2 -2
- data/lib/temporalio/converters/payload_converter/json_protobuf.rb +2 -2
- data/lib/temporalio/converters/payload_converter.rb +16 -6
- data/lib/temporalio/error/failure.rb +19 -1
- data/lib/temporalio/error.rb +2 -1
- data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +1 -1
- data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +3 -2
- data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +1 -1
- data/lib/temporalio/internal/bridge/api/common/common.rb +3 -2
- data/lib/temporalio/internal/bridge/api/core_interface.rb +1 -1
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +1 -1
- data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +3 -2
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +2 -2
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +3 -2
- data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +3 -2
- data/lib/temporalio/internal/bridge/runtime.rb +3 -0
- data/lib/temporalio/internal/bridge/testing.rb +3 -0
- data/lib/temporalio/internal/bridge/worker.rb +28 -4
- data/lib/temporalio/internal/bridge.rb +1 -1
- data/lib/temporalio/internal/client/implementation.rb +281 -51
- data/lib/temporalio/internal/proto_utils.rb +38 -6
- data/lib/temporalio/internal/worker/activity_worker.rb +112 -27
- data/lib/temporalio/internal/worker/multi_runner.rb +2 -2
- data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +8 -6
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +100 -5
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +7 -2
- data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +2 -2
- data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +64 -18
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +39 -40
- data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +22 -2
- data/lib/temporalio/internal/worker/workflow_instance.rb +134 -55
- data/lib/temporalio/internal/worker/workflow_worker.rb +74 -21
- data/lib/temporalio/priority.rb +59 -0
- data/lib/temporalio/runtime/metric_buffer.rb +94 -0
- data/lib/temporalio/runtime.rb +48 -10
- data/lib/temporalio/search_attributes.rb +13 -0
- data/lib/temporalio/testing/activity_environment.rb +59 -16
- data/lib/temporalio/testing/workflow_environment.rb +29 -6
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/versioning_override.rb +56 -0
- data/lib/temporalio/worker/deployment_options.rb +45 -0
- data/lib/temporalio/worker/illegal_workflow_call_validator.rb +64 -0
- data/lib/temporalio/worker/interceptor.rb +16 -1
- data/lib/temporalio/worker/poller_behavior.rb +61 -0
- data/lib/temporalio/worker/thread_pool.rb +6 -6
- data/lib/temporalio/worker/tuner.rb +38 -0
- data/lib/temporalio/worker/workflow_executor/thread_pool.rb +14 -8
- data/lib/temporalio/worker/workflow_executor.rb +1 -1
- data/lib/temporalio/worker/workflow_replayer.rb +349 -0
- data/lib/temporalio/worker.rb +117 -75
- data/lib/temporalio/worker_deployment_version.rb +67 -0
- data/lib/temporalio/workflow/child_workflow_handle.rb +10 -2
- data/lib/temporalio/workflow/definition.rb +217 -35
- data/lib/temporalio/workflow/external_workflow_handle.rb +3 -1
- data/lib/temporalio/workflow/future.rb +2 -2
- data/lib/temporalio/workflow/info.rb +26 -1
- data/lib/temporalio/workflow.rb +119 -15
- data/lib/temporalio/workflow_history.rb +26 -1
- data/lib/temporalio.rb +1 -0
- data/temporalio.gemspec +3 -1
- metadata +36 -6
@@ -167,12 +167,15 @@ module Temporalio
|
|
167
167
|
:args,
|
168
168
|
:id,
|
169
169
|
:task_queue,
|
170
|
+
:static_summary,
|
171
|
+
:static_details,
|
170
172
|
:execution_timeout,
|
171
173
|
:run_timeout,
|
172
174
|
:task_timeout,
|
173
175
|
:retry_policy,
|
174
176
|
:memo,
|
175
177
|
:search_attributes,
|
178
|
+
:arg_hints,
|
176
179
|
:headers
|
177
180
|
)
|
178
181
|
|
@@ -186,6 +189,14 @@ module Temporalio
|
|
186
189
|
# @return [String] Unique identifier for the workflow execution.
|
187
190
|
# @!attribute task_queue
|
188
191
|
# @return [String] Task queue to run the workflow on.
|
192
|
+
# @!attribute static_summary
|
193
|
+
# @return [String, nil] Fixed single-line summary for this workflow execution that may appear in CLI/UI.
|
194
|
+
# This can be in single-line Temporal markdown format. This is currently experimental.
|
195
|
+
# @!attribute static_details
|
196
|
+
# @return [String, nil] Fixed details for this workflow execution that may appear in CLI/UI. This can be in
|
197
|
+
# Temporal markdown format and can be multiple lines. This is a fixed value on the workflow that cannot be
|
198
|
+
# updated. For details that can be updated, use {Workflow.current_details=} within the workflow. This is
|
199
|
+
# currently experimental.
|
189
200
|
# @!attribute execution_timeout
|
190
201
|
# @return [Float, nil] Total workflow execution timeout in seconds including retries and continue as new.
|
191
202
|
# @!attribute run_timeout
|
@@ -198,6 +209,9 @@ module Temporalio
|
|
198
209
|
# @return [Hash<String, Object>, nil] Memo for the workflow.
|
199
210
|
# @!attribute search_attributes
|
200
211
|
# @return [SearchAttributes, nil] Search attributes for the workflow.
|
212
|
+
# @!attribute arg_hints
|
213
|
+
# @return [Array<Object>, nil] Converter hints for workflow arguments. This is only user-set (e.g. on create)
|
214
|
+
# and is not persisted and therefore will not be set when describing a workflow.
|
201
215
|
# @!attribute headers
|
202
216
|
# @return [Hash<String, Object>, nil] Headers for the workflow.
|
203
217
|
class StartWorkflow
|
@@ -212,6 +226,12 @@ module Temporalio
|
|
212
226
|
# @param args [Array<Object>] Arguments to the workflow.
|
213
227
|
# @param id [String] Unique identifier for the workflow execution.
|
214
228
|
# @param task_queue [String] Task queue to run the workflow on.
|
229
|
+
# @param static_summary [String, nil] Fixed single-line summary for this workflow execution that may appear
|
230
|
+
# in CLI/UI. This can be in single-line Temporal markdown format. This is currently experimental.
|
231
|
+
# @param static_details [String, nil] Fixed details for this workflow execution that may appear in CLI/UI.
|
232
|
+
# This can be in Temporal markdown format and can be multiple lines. This is a fixed value on the workflow
|
233
|
+
# that cannot be updated. For details that can be updated, use {Workflow.current_details=} within the
|
234
|
+
# workflow. This is currently experimental.
|
215
235
|
# @param execution_timeout [Float, nil] Total workflow execution timeout in seconds including retries and
|
216
236
|
# continue as new.
|
217
237
|
# @param run_timeout [Float, nil] Timeout of a single workflow run in seconds.
|
@@ -225,25 +245,33 @@ module Temporalio
|
|
225
245
|
*args,
|
226
246
|
id:,
|
227
247
|
task_queue:,
|
248
|
+
static_summary: nil,
|
249
|
+
static_details: nil,
|
228
250
|
execution_timeout: nil,
|
229
251
|
run_timeout: nil,
|
230
252
|
task_timeout: nil,
|
231
253
|
retry_policy: nil,
|
232
254
|
memo: nil,
|
233
255
|
search_attributes: nil,
|
256
|
+
arg_hints: nil,
|
234
257
|
headers: nil
|
235
258
|
)
|
259
|
+
workflow, defn_arg_hints, =
|
260
|
+
Workflow::Definition._workflow_type_and_hints_from_workflow_parameter(workflow)
|
236
261
|
_original_new( # steep:ignore
|
237
|
-
workflow
|
262
|
+
workflow:,
|
238
263
|
args:,
|
239
264
|
id:,
|
240
265
|
task_queue:,
|
266
|
+
static_summary:,
|
267
|
+
static_details:,
|
241
268
|
execution_timeout:,
|
242
269
|
run_timeout:,
|
243
270
|
task_timeout:,
|
244
271
|
retry_policy:,
|
245
272
|
memo:,
|
246
273
|
search_attributes:,
|
274
|
+
arg_hints: arg_hints || defn_arg_hints,
|
247
275
|
headers:
|
248
276
|
)
|
249
277
|
end
|
@@ -251,11 +279,14 @@ module Temporalio
|
|
251
279
|
|
252
280
|
# @!visibility private
|
253
281
|
def self._from_proto(raw_info, data_converter)
|
282
|
+
(summary, details) = Internal::ProtoUtils.from_user_metadata(raw_info.user_metadata, data_converter)
|
254
283
|
StartWorkflow.new(
|
255
284
|
raw_info.workflow_type.name,
|
256
285
|
*data_converter.from_payloads(raw_info.input),
|
257
286
|
id: raw_info.workflow_id,
|
258
287
|
task_queue: raw_info.task_queue.name,
|
288
|
+
static_summary: summary,
|
289
|
+
static_details: details,
|
259
290
|
execution_timeout: Internal::ProtoUtils.duration_to_seconds(raw_info.workflow_execution_timeout),
|
260
291
|
run_timeout: Internal::ProtoUtils.duration_to_seconds(raw_info.workflow_run_timeout),
|
261
292
|
task_timeout: Internal::ProtoUtils.duration_to_seconds(raw_info.workflow_task_timeout),
|
@@ -273,14 +304,15 @@ module Temporalio
|
|
273
304
|
workflow_id: id,
|
274
305
|
workflow_type: Api::Common::V1::WorkflowType.new(name: workflow),
|
275
306
|
task_queue: Api::TaskQueue::V1::TaskQueue.new(name: task_queue),
|
276
|
-
input: data_converter.to_payloads(args),
|
307
|
+
input: data_converter.to_payloads(args, hints: arg_hints),
|
277
308
|
workflow_execution_timeout: Internal::ProtoUtils.seconds_to_duration(execution_timeout),
|
278
309
|
workflow_run_timeout: Internal::ProtoUtils.seconds_to_duration(run_timeout),
|
279
310
|
workflow_task_timeout: Internal::ProtoUtils.seconds_to_duration(task_timeout),
|
280
311
|
retry_policy: retry_policy&._to_proto,
|
281
312
|
memo: Internal::ProtoUtils.memo_to_proto(memo, data_converter),
|
282
313
|
search_attributes: search_attributes&._to_proto,
|
283
|
-
header: Internal::ProtoUtils.headers_to_proto(headers, data_converter)
|
314
|
+
header: Internal::ProtoUtils.headers_to_proto(headers, data_converter),
|
315
|
+
user_metadata: Internal::ProtoUtils.to_user_metadata(static_summary, static_details, data_converter)
|
284
316
|
)
|
285
317
|
)
|
286
318
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/common_enums'
|
4
|
+
|
5
|
+
module Temporalio
|
6
|
+
class Client
|
7
|
+
# Start operation used by {Client.start_update_with_start_workflow}, {Client.execute_update_with_start_workflow},
|
8
|
+
# and {Client.signal_with_start_workflow}.
|
9
|
+
class WithStartWorkflowOperation
|
10
|
+
Options = Data.define(
|
11
|
+
:workflow,
|
12
|
+
:args,
|
13
|
+
:id,
|
14
|
+
:task_queue,
|
15
|
+
:static_summary,
|
16
|
+
:static_details,
|
17
|
+
:execution_timeout,
|
18
|
+
:run_timeout,
|
19
|
+
:task_timeout,
|
20
|
+
:id_reuse_policy,
|
21
|
+
:id_conflict_policy,
|
22
|
+
:retry_policy,
|
23
|
+
:cron_schedule,
|
24
|
+
:memo,
|
25
|
+
:search_attributes,
|
26
|
+
:start_delay,
|
27
|
+
:arg_hints,
|
28
|
+
:result_hint,
|
29
|
+
:headers
|
30
|
+
)
|
31
|
+
|
32
|
+
# Options the operation was created with.
|
33
|
+
class Options; end # rubocop:disable Lint/EmptyClass
|
34
|
+
|
35
|
+
# @return [Options] Options the operation was created with.
|
36
|
+
attr_accessor :options
|
37
|
+
|
38
|
+
# Create a with-start workflow operation. These are mostly the same options as {Client.start_workflow}, see that
|
39
|
+
# documentation for more details.
|
40
|
+
#
|
41
|
+
# Note, for {Client.start_update_with_start_workflow} and {Client.execute_update_with_start_workflow},
|
42
|
+
# `id_conflict_policy` is required.
|
43
|
+
def initialize(
|
44
|
+
workflow,
|
45
|
+
*args,
|
46
|
+
id:,
|
47
|
+
task_queue:,
|
48
|
+
static_summary: nil,
|
49
|
+
static_details: nil,
|
50
|
+
execution_timeout: nil,
|
51
|
+
run_timeout: nil,
|
52
|
+
task_timeout: nil,
|
53
|
+
id_reuse_policy: WorkflowIDReusePolicy::ALLOW_DUPLICATE,
|
54
|
+
id_conflict_policy: WorkflowIDConflictPolicy::UNSPECIFIED,
|
55
|
+
retry_policy: nil,
|
56
|
+
cron_schedule: nil,
|
57
|
+
memo: nil,
|
58
|
+
search_attributes: nil,
|
59
|
+
start_delay: nil,
|
60
|
+
arg_hints: nil,
|
61
|
+
result_hint: nil,
|
62
|
+
headers: {}
|
63
|
+
)
|
64
|
+
workflow, defn_arg_hints, defn_result_hint =
|
65
|
+
Workflow::Definition._workflow_type_and_hints_from_workflow_parameter(workflow)
|
66
|
+
@options = Options.new(
|
67
|
+
workflow:,
|
68
|
+
args:,
|
69
|
+
id:,
|
70
|
+
task_queue:,
|
71
|
+
static_summary:,
|
72
|
+
static_details:,
|
73
|
+
execution_timeout:,
|
74
|
+
run_timeout:,
|
75
|
+
task_timeout:,
|
76
|
+
id_reuse_policy:,
|
77
|
+
id_conflict_policy:,
|
78
|
+
retry_policy:,
|
79
|
+
cron_schedule:,
|
80
|
+
memo:,
|
81
|
+
search_attributes:,
|
82
|
+
start_delay:,
|
83
|
+
arg_hints: arg_hints || defn_arg_hints,
|
84
|
+
result_hint: result_hint || defn_result_hint,
|
85
|
+
headers:
|
86
|
+
)
|
87
|
+
@workflow_handle_mutex = Mutex.new
|
88
|
+
@workflow_handle_cond_var = ConditionVariable.new
|
89
|
+
end
|
90
|
+
|
91
|
+
# Get the workflow handle, possibly waiting until set, or raise an error if the workflow start was unsuccessful.
|
92
|
+
#
|
93
|
+
# @param wait [Boolean] True to wait until it is set, false to return immediately.
|
94
|
+
#
|
95
|
+
# @return [WorkflowHandle, nil] The workflow handle when available or `nil` if `wait` is false and it is not set
|
96
|
+
# yet.
|
97
|
+
# @raise [Error] Any error that occurred during the call before the workflow start returned.
|
98
|
+
def workflow_handle(wait: true)
|
99
|
+
@workflow_handle_mutex.synchronize do
|
100
|
+
@workflow_handle_cond_var.wait(@workflow_handle_mutex) unless @workflow_handle || !wait
|
101
|
+
raise @workflow_handle if @workflow_handle.is_a?(Exception)
|
102
|
+
|
103
|
+
@workflow_handle
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# @!visibility private
|
108
|
+
def _set_workflow_handle(value)
|
109
|
+
@workflow_handle_mutex.synchronize do
|
110
|
+
@workflow_handle ||= value
|
111
|
+
@workflow_handle_cond_var.broadcast
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# @!visibility private
|
116
|
+
def _mark_used
|
117
|
+
raise 'Start operation already used' if @in_use
|
118
|
+
|
119
|
+
@in_use = true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -93,6 +93,25 @@ module Temporalio
|
|
93
93
|
def initialize(raw_description, data_converter)
|
94
94
|
super(raw_description.workflow_execution_info, data_converter)
|
95
95
|
@raw_description = raw_description
|
96
|
+
@data_converter = data_converter
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [String, nil] Static summary configured on the workflow. This is currently experimental.
|
100
|
+
def static_summary
|
101
|
+
user_metadata.first
|
102
|
+
end
|
103
|
+
|
104
|
+
# @return [String, nil] Static details configured on the workflow. This is currently experimental.
|
105
|
+
def static_details
|
106
|
+
user_metadata.last
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def user_metadata
|
112
|
+
@user_metadata ||= Internal::ProtoUtils.from_user_metadata(
|
113
|
+
@raw_description.execution_config&.user_metadata, @data_converter
|
114
|
+
)
|
96
115
|
end
|
97
116
|
end
|
98
117
|
end
|
@@ -48,13 +48,21 @@ module Temporalio
|
|
48
48
|
# @return [String, nil] First execution run ID.
|
49
49
|
attr_reader :first_execution_run_id
|
50
50
|
|
51
|
+
# Result hint for the result of this workflow. If this handle was created via {Client.start_workflow}, this is set
|
52
|
+
# from there (either via result hint on that call or workflow definition's result hint). Otherwise, the result
|
53
|
+
# hint is set by the creator of the handle.
|
54
|
+
#
|
55
|
+
# @return [Object, nil] Result hint.
|
56
|
+
attr_reader :result_hint
|
57
|
+
|
51
58
|
# @!visibility private
|
52
|
-
def initialize(client:, id:, run_id:, result_run_id:, first_execution_run_id:)
|
59
|
+
def initialize(client:, id:, run_id:, result_run_id:, first_execution_run_id:, result_hint:)
|
53
60
|
@client = client
|
54
61
|
@id = id
|
55
62
|
@run_id = run_id
|
56
63
|
@result_run_id = result_run_id
|
57
64
|
@first_execution_run_id = first_execution_run_id
|
65
|
+
@result_hint = result_hint
|
58
66
|
end
|
59
67
|
|
60
68
|
# Wait for the result of the workflow.
|
@@ -64,6 +72,8 @@ module Temporalio
|
|
64
72
|
#
|
65
73
|
# @param follow_runs [Boolean] If +true+, workflow runs will be continually fetched across retries and continue as
|
66
74
|
# new until the latest one is found. If +false+, the first result is used.
|
75
|
+
# @param result_hint [Object, nil] Override the result hint for the result. If unset/nil, uses one on the handle
|
76
|
+
# itself.
|
67
77
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
68
78
|
#
|
69
79
|
# @return [Object] Result of the workflow after being converted by the data converter.
|
@@ -71,7 +81,7 @@ module Temporalio
|
|
71
81
|
# @raise [Error::WorkflowFailedError] Workflow failed with +cause+ as the cause.
|
72
82
|
# @raise [Error::WorkflowContinuedAsNewError] Workflow continued as new and +follow_runs+ is +false+.
|
73
83
|
# @raise [Error::RPCError] RPC error from call.
|
74
|
-
def result(follow_runs: true, rpc_options: nil)
|
84
|
+
def result(follow_runs: true, result_hint: nil, rpc_options: nil)
|
75
85
|
# Wait on the close event, following as needed
|
76
86
|
hist_run_id = result_run_id
|
77
87
|
loop do
|
@@ -91,7 +101,7 @@ module Temporalio
|
|
91
101
|
hist_run_id = attrs.new_execution_run_id
|
92
102
|
next if follow_runs && hist_run_id && !hist_run_id.empty?
|
93
103
|
|
94
|
-
return @client.data_converter.from_payloads(attrs.result).first
|
104
|
+
return @client.data_converter.from_payloads(attrs.result, hints: Array(@result_hint || result_hint)).first
|
95
105
|
when :EVENT_TYPE_WORKFLOW_EXECUTION_FAILED
|
96
106
|
attrs = event.workflow_execution_failed_event_attributes
|
97
107
|
hist_run_id = attrs.new_execution_run_id
|
@@ -212,18 +222,22 @@ module Temporalio
|
|
212
222
|
#
|
213
223
|
# @param signal [Workflow::Definition::Signal, Symbol, String] Signal definition or name.
|
214
224
|
# @param args [Array<Object>] Signal arguments.
|
225
|
+
# @param arg_hints [Array<Object>, nil] Signal argument hints. If unset/nil and a signal definition is passed,
|
226
|
+
# uses the ones on the signal definition if present.
|
215
227
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
216
228
|
#
|
217
229
|
# @raise [Error::RPCError] RPC error from call.
|
218
230
|
#
|
219
231
|
# @note Handles created as a result of {Client.start_workflow} will signal the latest workflow with the same
|
220
232
|
# workflow ID even if it is unrelated to the started workflow.
|
221
|
-
def signal(signal, *args, rpc_options: nil)
|
233
|
+
def signal(signal, *args, arg_hints: nil, rpc_options: nil)
|
234
|
+
signal, defn_arg_hints = Workflow::Definition::Signal._name_and_hints_from_parameter(signal)
|
222
235
|
@client._impl.signal_workflow(Interceptor::SignalWorkflowInput.new(
|
223
236
|
workflow_id: id,
|
224
237
|
run_id:,
|
225
238
|
signal:,
|
226
239
|
args:,
|
240
|
+
arg_hints: arg_hints || defn_arg_hints,
|
227
241
|
headers: {},
|
228
242
|
rpc_options:
|
229
243
|
))
|
@@ -235,6 +249,10 @@ module Temporalio
|
|
235
249
|
# @param query [Workflow::Definition::Query, Symbol, String] Query definition or name.
|
236
250
|
# @param args [Array<Object>] Query arguments.
|
237
251
|
# @param reject_condition [WorkflowQueryRejectCondition, nil] Condition for rejecting the query.
|
252
|
+
# @param arg_hints [Array<Object>, nil] Query argument hints. If unset/nil and a query definition is passed,
|
253
|
+
# uses the ones on the query definition if present.
|
254
|
+
# @param result_hint [Object, nil] Query result hints. If unset/nil and a query definition is passed, uses the
|
255
|
+
# one on the query definition if present.
|
238
256
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
239
257
|
#
|
240
258
|
# @return [Object, nil] Query result.
|
@@ -249,14 +267,19 @@ module Temporalio
|
|
249
267
|
query,
|
250
268
|
*args,
|
251
269
|
reject_condition: @client.options.default_workflow_query_reject_condition,
|
270
|
+
arg_hints: nil,
|
271
|
+
result_hint: nil,
|
252
272
|
rpc_options: nil
|
253
273
|
)
|
274
|
+
query, defn_arg_hints, defn_result_hint = Workflow::Definition::Query._name_and_hints_from_parameter(query)
|
254
275
|
@client._impl.query_workflow(Interceptor::QueryWorkflowInput.new(
|
255
276
|
workflow_id: id,
|
256
277
|
run_id:,
|
257
278
|
query:,
|
258
279
|
args:,
|
259
280
|
reject_condition:,
|
281
|
+
arg_hints: arg_hints || defn_arg_hints,
|
282
|
+
result_hint: result_hint || defn_result_hint,
|
260
283
|
headers: {},
|
261
284
|
rpc_options:
|
262
285
|
))
|
@@ -270,6 +293,10 @@ module Temporalio
|
|
270
293
|
# @param wait_for_stage [WorkflowUpdateWaitStage] Required stage to wait until returning. ADMITTED is not
|
271
294
|
# currently supported. See https://docs.temporal.io/workflows#update for more details.
|
272
295
|
# @param id [String] ID of the update.
|
296
|
+
# @param arg_hints [Array<Object>, nil] Update argument hints. If unset/nil and am update definition is passed,
|
297
|
+
# uses the ones on the update definition if present.
|
298
|
+
# @param result_hint [Object, nil] Update result hints. If unset/nil and an update definition is passed, uses the
|
299
|
+
# one on the update definition if present.
|
273
300
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
274
301
|
#
|
275
302
|
# @return [WorkflowUpdateHandle] The update handle.
|
@@ -285,8 +312,11 @@ module Temporalio
|
|
285
312
|
*args,
|
286
313
|
wait_for_stage:,
|
287
314
|
id: SecureRandom.uuid,
|
315
|
+
arg_hints: nil,
|
316
|
+
result_hint: nil,
|
288
317
|
rpc_options: nil
|
289
318
|
)
|
319
|
+
update, defn_arg_hints, defn_result_hint = Workflow::Definition::Update._name_and_hints_from_parameter(update)
|
290
320
|
@client._impl.start_workflow_update(Interceptor::StartWorkflowUpdateInput.new(
|
291
321
|
workflow_id: self.id,
|
292
322
|
run_id:,
|
@@ -294,6 +324,8 @@ module Temporalio
|
|
294
324
|
update:,
|
295
325
|
args:,
|
296
326
|
wait_for_stage:,
|
327
|
+
arg_hints: arg_hints || defn_arg_hints,
|
328
|
+
result_hint: result_hint || defn_result_hint,
|
297
329
|
headers: {},
|
298
330
|
rpc_options:
|
299
331
|
))
|
@@ -305,6 +337,10 @@ module Temporalio
|
|
305
337
|
# @param update [Workflow::Definition::Update, Symbol, String] Update definition or name.
|
306
338
|
# @param args [Array<Object>] Update arguments.
|
307
339
|
# @param id [String] ID of the update.
|
340
|
+
# @param arg_hints [Array<Object>, nil] Update argument hints. If unset/nil and am update definition is passed,
|
341
|
+
# uses the ones on the update definition if present.
|
342
|
+
# @param result_hint [Object, nil] Update result hints. If unset/nil and an update definition is passed, uses the
|
343
|
+
# one on the update definition if present.
|
308
344
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
309
345
|
#
|
310
346
|
# @return [Object, nil] Update result.
|
@@ -316,12 +352,14 @@ module Temporalio
|
|
316
352
|
#
|
317
353
|
# @note Handles created as a result of {Client.start_workflow} will send updates the latest workflow with the same
|
318
354
|
# workflow ID even if it is unrelated to the started workflow.
|
319
|
-
def execute_update(update, *args, id: SecureRandom.uuid, rpc_options: nil)
|
355
|
+
def execute_update(update, *args, id: SecureRandom.uuid, arg_hints: nil, result_hint: nil, rpc_options: nil)
|
320
356
|
start_update(
|
321
357
|
update,
|
322
358
|
*args,
|
323
359
|
wait_for_stage: WorkflowUpdateWaitStage::COMPLETED,
|
324
360
|
id:,
|
361
|
+
arg_hints:,
|
362
|
+
result_hint:,
|
325
363
|
rpc_options:
|
326
364
|
).result
|
327
365
|
end
|
@@ -331,15 +369,17 @@ module Temporalio
|
|
331
369
|
# @param id [String] ID of the update.
|
332
370
|
# @param specific_run_id [String, nil] Workflow run ID to get update handle for. Default is the {run_id}. Most
|
333
371
|
# users will not need to set this and instead use the one on the class.
|
372
|
+
# @param result_hint [Object, nil] Result hint for the update result to set on the handle.
|
334
373
|
#
|
335
374
|
# @return [WorkflowUpdateHandle] The update handle.
|
336
|
-
def update_handle(id, specific_run_id: run_id)
|
375
|
+
def update_handle(id, specific_run_id: run_id, result_hint: nil)
|
337
376
|
WorkflowUpdateHandle.new(
|
338
377
|
client: @client,
|
339
378
|
id:,
|
340
379
|
workflow_id: self.id,
|
341
380
|
workflow_run_id: specific_run_id,
|
342
|
-
known_outcome: nil
|
381
|
+
known_outcome: nil,
|
382
|
+
result_hint:
|
343
383
|
)
|
344
384
|
end
|
345
385
|
|
@@ -18,13 +18,17 @@ module Temporalio
|
|
18
18
|
# @return [String, nil] Run ID for the workflow.
|
19
19
|
attr_reader :workflow_run_id
|
20
20
|
|
21
|
+
# @return [Object, nil] Result hint if one set when the handle was created.
|
22
|
+
attr_reader :result_hint
|
23
|
+
|
21
24
|
# @!visibility private
|
22
|
-
def initialize(client:, id:, workflow_id:, workflow_run_id:, known_outcome:)
|
25
|
+
def initialize(client:, id:, workflow_id:, workflow_run_id:, known_outcome:, result_hint:)
|
23
26
|
@client = client
|
24
27
|
@id = id
|
25
28
|
@workflow_id = workflow_id
|
26
29
|
@workflow_run_id = workflow_run_id
|
27
30
|
@known_outcome = known_outcome
|
31
|
+
@result_hint = result_hint
|
28
32
|
end
|
29
33
|
|
30
34
|
# @return [Boolean] True if the result is already known and {result} will not make a blocking call, false if
|
@@ -36,6 +40,7 @@ module Temporalio
|
|
36
40
|
# Wait for and return the result of the update. The result may already be known in which case no network call is
|
37
41
|
# made. Otherwise the result will be polled for until it is returned.
|
38
42
|
#
|
43
|
+
# @param result_hint [Object, nil] If not nil, overrides handle-level result hint for getting the result.
|
39
44
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
40
45
|
#
|
41
46
|
# @return [Object, nil] Update result.
|
@@ -44,7 +49,7 @@ module Temporalio
|
|
44
49
|
# @raise [Error::WorkflowUpdateRPCTimeoutOrCanceledError] This update call timed out or was canceled. This doesn't
|
45
50
|
# mean the update itself was timed out or canceled.
|
46
51
|
# @raise [Error::RPCError] RPC error from call.
|
47
|
-
def result(rpc_options: nil)
|
52
|
+
def result(result_hint: nil, rpc_options: nil)
|
48
53
|
@known_outcome ||= @client._impl.poll_workflow_update(Interceptor::PollWorkflowUpdateInput.new(
|
49
54
|
workflow_id:,
|
50
55
|
run_id: workflow_run_id,
|
@@ -56,7 +61,8 @@ module Temporalio
|
|
56
61
|
raise Error::WorkflowUpdateFailedError.new, cause: @client.data_converter.from_failure(@known_outcome.failure)
|
57
62
|
end
|
58
63
|
|
59
|
-
results = @client.data_converter.from_payloads(@known_outcome.success
|
64
|
+
results = @client.data_converter.from_payloads(@known_outcome.success,
|
65
|
+
hints: Array(result_hint || @result_hint))
|
60
66
|
warn("Expected 0 or 1 update result, got #{results.size}") if results.size > 1
|
61
67
|
results.first
|
62
68
|
end
|