temporalio 0.4.0-x86_64-linux → 0.5.0-x86_64-linux
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/lib/temporalio/activity/cancellation_details.rb +58 -0
- data/lib/temporalio/activity/context.rb +10 -1
- data/lib/temporalio/activity/definition.rb +41 -3
- data/lib/temporalio/activity/info.rb +25 -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 +4 -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 +3 -2
- data/lib/temporalio/api/deployment/v1/message.rb +3 -2
- data/lib/temporalio/api/enums/v1/batch_operation.rb +1 -1
- 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 +3 -2
- 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 +1 -1
- data/lib/temporalio/api/enums/v1/query.rb +1 -1
- data/lib/temporalio/api/enums/v1/reset.rb +1 -1
- 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 +2 -2
- data/lib/temporalio/api/errordetails/v1/message.rb +1 -1
- data/lib/temporalio/api/export/v1/message.rb +1 -1
- data/lib/temporalio/api/failure/v1/message.rb +3 -2
- data/lib/temporalio/api/filter/v1/message.rb +1 -1
- data/lib/temporalio/api/history/v1/message.rb +4 -2
- data/lib/temporalio/api/namespace/v1/message.rb +1 -1
- data/lib/temporalio/api/nexus/v1/message.rb +2 -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 +87 -0
- data/lib/temporalio/api/protocol/v1/message.rb +1 -1
- data/lib/temporalio/api/query/v1/message.rb +1 -1
- 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 +2 -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 +14 -2
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +19 -2
- data/lib/temporalio/api/workflowservice/v1/service.rb +2 -2
- 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 +105 -0
- data/lib/temporalio/client/interceptor.rb +25 -7
- data/lib/temporalio/client/schedule.rb +10 -2
- data/lib/temporalio/client/with_start_workflow_operation.rb +9 -1
- data/lib/temporalio/client/workflow_handle.rb +50 -10
- data/lib/temporalio/client/workflow_update_handle.rb +9 -3
- data/lib/temporalio/client.rb +110 -6
- data/lib/temporalio/common_enums.rb +14 -0
- data/lib/temporalio/contrib/open_telemetry.rb +13 -9
- 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 +1 -1
- 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 +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 +1 -1
- 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 +1 -1
- data/lib/temporalio/internal/bridge/worker.rb +28 -4
- data/lib/temporalio/internal/bridge.rb +1 -1
- data/lib/temporalio/internal/client/implementation.rb +60 -52
- data/lib/temporalio/internal/proto_utils.rb +4 -4
- data/lib/temporalio/internal/worker/activity_worker.rb +93 -20
- data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +8 -6
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +65 -24
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +5 -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 +28 -14
- data/lib/temporalio/internal/worker/workflow_instance.rb +58 -23
- data/lib/temporalio/internal/worker/workflow_worker.rb +16 -6
- data/lib/temporalio/priority.rb +59 -0
- data/lib/temporalio/testing/activity_environment.rb +17 -2
- data/lib/temporalio/testing/workflow_environment.rb +3 -3
- 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 +13 -1
- data/lib/temporalio/worker/poller_behavior.rb +61 -0
- data/lib/temporalio/worker/thread_pool.rb +1 -1
- data/lib/temporalio/worker/workflow_executor/thread_pool.rb +2 -1
- data/lib/temporalio/worker/workflow_replayer.rb +12 -13
- data/lib/temporalio/worker.rb +63 -27
- 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 +183 -33
- data/lib/temporalio/workflow/external_workflow_handle.rb +3 -1
- data/lib/temporalio/workflow/info.rb +4 -1
- data/lib/temporalio/workflow.rb +61 -9
- data/lib/temporalio.rb +1 -0
- data/temporalio.gemspec +1 -0
- metadata +11 -2
@@ -42,6 +42,10 @@ module Temporalio
|
|
42
42
|
@instance.current_details = (details || '')
|
43
43
|
end
|
44
44
|
|
45
|
+
def current_deployment_version
|
46
|
+
@instance.current_deployment_version
|
47
|
+
end
|
48
|
+
|
45
49
|
def current_history_length
|
46
50
|
@instance.current_history_length
|
47
51
|
end
|
@@ -58,6 +62,16 @@ module Temporalio
|
|
58
62
|
@instance.patch(patch_id:, deprecated: true)
|
59
63
|
end
|
60
64
|
|
65
|
+
def durable_scheduler_disabled(&)
|
66
|
+
prev = Fiber.current_scheduler
|
67
|
+
illegal_call_tracing_disabled { Fiber.set_scheduler(nil) }
|
68
|
+
begin
|
69
|
+
yield
|
70
|
+
ensure
|
71
|
+
illegal_call_tracing_disabled { Fiber.set_scheduler(prev) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
61
75
|
def execute_activity(
|
62
76
|
activity,
|
63
77
|
*args,
|
@@ -71,16 +85,22 @@ module Temporalio
|
|
71
85
|
cancellation:,
|
72
86
|
cancellation_type:,
|
73
87
|
activity_id:,
|
74
|
-
disable_eager_execution
|
88
|
+
disable_eager_execution:,
|
89
|
+
priority:,
|
90
|
+
arg_hints:,
|
91
|
+
result_hint:
|
75
92
|
)
|
76
|
-
activity
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
93
|
+
activity, defn_arg_hints, defn_result_hint =
|
94
|
+
case activity
|
95
|
+
when Class
|
96
|
+
defn = Activity::Definition::Info.from_activity(activity)
|
97
|
+
[defn.name&.to_s, defn.arg_hints, defn.result_hint]
|
98
|
+
when Symbol, String
|
99
|
+
[activity.to_s, nil, nil]
|
100
|
+
else
|
101
|
+
raise ArgumentError,
|
102
|
+
'Activity must be a definition class, or a symbol/string'
|
103
|
+
end
|
84
104
|
raise 'Cannot invoke dynamic activities' unless activity
|
85
105
|
|
86
106
|
@outbound.execute_activity(
|
@@ -98,6 +118,9 @@ module Temporalio
|
|
98
118
|
cancellation_type:,
|
99
119
|
activity_id:,
|
100
120
|
disable_eager_execution: disable_eager_execution || @instance.disable_eager_activity_execution,
|
121
|
+
priority:,
|
122
|
+
arg_hints: arg_hints || defn_arg_hints,
|
123
|
+
result_hint: result_hint || defn_result_hint,
|
101
124
|
headers: {}
|
102
125
|
)
|
103
126
|
)
|
@@ -113,16 +136,20 @@ module Temporalio
|
|
113
136
|
local_retry_threshold:,
|
114
137
|
cancellation:,
|
115
138
|
cancellation_type:,
|
116
|
-
activity_id
|
139
|
+
activity_id:,
|
140
|
+
arg_hints:,
|
141
|
+
result_hint:
|
117
142
|
)
|
118
|
-
activity
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
143
|
+
activity, defn_arg_hints, defn_result_hint =
|
144
|
+
case activity
|
145
|
+
when Class
|
146
|
+
defn = Activity::Definition::Info.from_activity(activity)
|
147
|
+
[defn.name&.to_s, defn.arg_hints, defn.result_hint]
|
148
|
+
when Symbol, String
|
149
|
+
[activity.to_s, nil, nil]
|
150
|
+
else
|
151
|
+
raise ArgumentError, 'Activity must be a definition class, or a symbol/string'
|
152
|
+
end
|
126
153
|
raise 'Cannot invoke dynamic activities' unless activity
|
127
154
|
|
128
155
|
@outbound.execute_local_activity(
|
@@ -137,6 +164,8 @@ module Temporalio
|
|
137
164
|
cancellation:,
|
138
165
|
cancellation_type:,
|
139
166
|
activity_id:,
|
167
|
+
arg_hints: arg_hints || defn_arg_hints,
|
168
|
+
result_hint: result_hint || defn_result_hint,
|
140
169
|
headers: {}
|
141
170
|
)
|
142
171
|
)
|
@@ -245,11 +274,16 @@ module Temporalio
|
|
245
274
|
retry_policy:,
|
246
275
|
cron_schedule:,
|
247
276
|
memo:,
|
248
|
-
search_attributes
|
277
|
+
search_attributes:,
|
278
|
+
priority:,
|
279
|
+
arg_hints:,
|
280
|
+
result_hint:
|
249
281
|
)
|
282
|
+
workflow, defn_arg_hints, defn_result_hint =
|
283
|
+
Workflow::Definition._workflow_type_and_hints_from_workflow_parameter(workflow)
|
250
284
|
@outbound.start_child_workflow(
|
251
285
|
Temporalio::Worker::Interceptor::Workflow::StartChildWorkflowInput.new(
|
252
|
-
workflow
|
286
|
+
workflow:,
|
253
287
|
args:,
|
254
288
|
id:,
|
255
289
|
task_queue:,
|
@@ -266,6 +300,9 @@ module Temporalio
|
|
266
300
|
cron_schedule:,
|
267
301
|
memo:,
|
268
302
|
search_attributes:,
|
303
|
+
priority:,
|
304
|
+
arg_hints: arg_hints || defn_arg_hints,
|
305
|
+
result_hint: result_hint || defn_result_hint,
|
269
306
|
headers: {}
|
270
307
|
)
|
271
308
|
)
|
@@ -352,26 +389,30 @@ module Temporalio
|
|
352
389
|
@outbound = outbound
|
353
390
|
end
|
354
391
|
|
355
|
-
def _signal_child_workflow(id:, signal:, args:, cancellation:)
|
392
|
+
def _signal_child_workflow(id:, signal:, args:, cancellation:, arg_hints:)
|
393
|
+
signal, defn_arg_hints = Workflow::Definition::Signal._name_and_hints_from_parameter(signal)
|
356
394
|
@outbound.signal_child_workflow(
|
357
395
|
Temporalio::Worker::Interceptor::Workflow::SignalChildWorkflowInput.new(
|
358
396
|
id:,
|
359
|
-
signal
|
397
|
+
signal:,
|
360
398
|
args:,
|
361
399
|
cancellation:,
|
400
|
+
arg_hints: arg_hints || defn_arg_hints,
|
362
401
|
headers: {}
|
363
402
|
)
|
364
403
|
)
|
365
404
|
end
|
366
405
|
|
367
|
-
def _signal_external_workflow(id:, run_id:, signal:, args:, cancellation:)
|
406
|
+
def _signal_external_workflow(id:, run_id:, signal:, args:, cancellation:, arg_hints:)
|
407
|
+
signal, defn_arg_hints = Workflow::Definition::Signal._name_and_hints_from_parameter(signal)
|
368
408
|
@outbound.signal_external_workflow(
|
369
409
|
Temporalio::Worker::Interceptor::Workflow::SignalExternalWorkflowInput.new(
|
370
410
|
id:,
|
371
411
|
run_id:,
|
372
|
-
signal
|
412
|
+
signal:,
|
373
413
|
args:,
|
374
414
|
cancellation:,
|
415
|
+
arg_hints: arg_hints || defn_arg_hints,
|
375
416
|
headers: {}
|
376
417
|
)
|
377
418
|
)
|
@@ -8,7 +8,8 @@ module Temporalio
|
|
8
8
|
class Details
|
9
9
|
attr_reader :namespace, :task_queue, :definition, :initial_activation, :logger, :metric_meter,
|
10
10
|
:payload_converter, :failure_converter, :interceptors, :disable_eager_activity_execution,
|
11
|
-
:illegal_calls, :workflow_failure_exception_types, :unsafe_workflow_io_enabled
|
11
|
+
:illegal_calls, :workflow_failure_exception_types, :unsafe_workflow_io_enabled,
|
12
|
+
:assert_valid_local_activity
|
12
13
|
|
13
14
|
def initialize(
|
14
15
|
namespace:,
|
@@ -23,7 +24,8 @@ module Temporalio
|
|
23
24
|
disable_eager_activity_execution:,
|
24
25
|
illegal_calls:,
|
25
26
|
workflow_failure_exception_types:,
|
26
|
-
unsafe_workflow_io_enabled
|
27
|
+
unsafe_workflow_io_enabled:,
|
28
|
+
assert_valid_local_activity:
|
27
29
|
)
|
28
30
|
@namespace = namespace
|
29
31
|
@task_queue = task_queue
|
@@ -38,6 +40,7 @@ module Temporalio
|
|
38
40
|
@illegal_calls = illegal_calls
|
39
41
|
@workflow_failure_exception_types = workflow_failure_exception_types
|
40
42
|
@unsafe_workflow_io_enabled = unsafe_workflow_io_enabled
|
43
|
+
@assert_valid_local_activity = assert_valid_local_activity
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -18,8 +18,8 @@ module Temporalio
|
|
18
18
|
@instance = instance
|
19
19
|
end
|
20
20
|
|
21
|
-
def signal(signal, *args, cancellation: Workflow.cancellation)
|
22
|
-
@instance.context._signal_external_workflow(id:, run_id:, signal:, args:, cancellation:)
|
21
|
+
def signal(signal, *args, cancellation: Workflow.cancellation, arg_hints: nil)
|
22
|
+
@instance.context._signal_external_workflow(id:, run_id:, signal:, args:, cancellation:, arg_hints:)
|
23
23
|
end
|
24
24
|
|
25
25
|
def cancel
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'temporalio/worker/illegal_workflow_call_validator'
|
3
4
|
require 'temporalio/workflow'
|
4
5
|
|
5
6
|
module Temporalio
|
@@ -12,16 +13,32 @@ module Temporalio
|
|
12
13
|
illegal_calls.to_h do |key, val|
|
13
14
|
raise TypeError, 'Invalid illegal call map, top-level key must be a String' unless key.is_a?(String)
|
14
15
|
|
15
|
-
# @type var fixed_val: :all | Hash[Symbol,
|
16
|
+
# @type var fixed_val: :all | Worker::IllegalWorkflowCallValidator | Hash[Symbol, TrueClass | Worker::IllegalWorkflowCallValidator] # rubocop:disable Layout/LineLength
|
16
17
|
fixed_val = case val
|
18
|
+
when Temporalio::Worker::IllegalWorkflowCallValidator
|
19
|
+
if sub_val.method_name
|
20
|
+
raise ArgumentError,
|
21
|
+
'Top level IllegalWorkflowCallValidator instances cannot have method name'
|
22
|
+
end
|
23
|
+
val
|
17
24
|
when Array
|
18
25
|
val.to_h do |sub_val|
|
19
|
-
|
26
|
+
case sub_val
|
27
|
+
when Symbol
|
28
|
+
[sub_val, true]
|
29
|
+
when Temporalio::Worker::IllegalWorkflowCallValidator
|
30
|
+
unless sub_val.method_name
|
31
|
+
raise ArgumentError,
|
32
|
+
'IllegalWorkflowCallValidator instances in array for ' \
|
33
|
+
"#{key} must have a method name"
|
34
|
+
end
|
35
|
+
|
36
|
+
[sub_val.method_name, sub_val]
|
37
|
+
else
|
20
38
|
raise TypeError,
|
21
|
-
'Invalid illegal call
|
39
|
+
'Invalid illegal call array entry for ' \
|
40
|
+
"#{key}, each value must be a Symbol or an IllegalWorkflowCallValidator"
|
22
41
|
end
|
23
|
-
|
24
|
-
[sub_val, true]
|
25
42
|
end.freeze
|
26
43
|
when :all
|
27
44
|
:all
|
@@ -47,25 +64,54 @@ module Temporalio
|
|
47
64
|
# class of things like `Date` does not have `attached_object` so you have to fall back in these rare cases
|
48
65
|
# to parsing the string output. Reaching the string parsing component is rare, so this should not have
|
49
66
|
# significant performance impact.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
67
|
+
class_name = if cls.singleton_class?
|
68
|
+
if cls.respond_to?(:attached_object)
|
69
|
+
cls = cls.attached_object # steep:ignore
|
70
|
+
next unless cls.is_a?(Module)
|
54
71
|
|
55
|
-
|
72
|
+
cls.name.to_s
|
73
|
+
else
|
74
|
+
cls.to_s.delete_prefix('#<Class:').delete_suffix('>')
|
75
|
+
end
|
56
76
|
else
|
57
|
-
cls.to_s
|
77
|
+
cls.name.to_s
|
58
78
|
end
|
59
|
-
else
|
60
|
-
cls.name.to_s
|
61
|
-
end
|
62
79
|
|
63
80
|
# Check if the call is considered illegal
|
64
|
-
vals = illegal_calls[
|
65
|
-
|
81
|
+
vals = illegal_calls[class_name]
|
82
|
+
invalid_suffix =
|
83
|
+
case vals
|
84
|
+
when :all
|
85
|
+
''
|
86
|
+
when Temporalio::Worker::IllegalWorkflowCallValidator
|
87
|
+
disable do
|
88
|
+
vals.block.call(Temporalio::Worker::IllegalWorkflowCallValidator::CallInfo.new(
|
89
|
+
class_name:, method_name: tp.callee_id, trace_point: tp
|
90
|
+
))
|
91
|
+
nil
|
92
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
93
|
+
", reason: #{e}"
|
94
|
+
end
|
95
|
+
else
|
96
|
+
per_method = vals&.[](tp.callee_id)
|
97
|
+
case per_method
|
98
|
+
when true
|
99
|
+
''
|
100
|
+
when Temporalio::Worker::IllegalWorkflowCallValidator
|
101
|
+
disable do
|
102
|
+
per_method.block.call(Temporalio::Worker::IllegalWorkflowCallValidator::CallInfo.new(
|
103
|
+
class_name:, method_name: tp.callee_id, trace_point: tp
|
104
|
+
))
|
105
|
+
nil
|
106
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
107
|
+
", reason: #{e}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
if invalid_suffix
|
66
112
|
raise Workflow::NondeterminismError,
|
67
|
-
"Cannot access #{
|
68
|
-
|
113
|
+
"Cannot access #{class_name} #{tp.callee_id} from inside a " \
|
114
|
+
"workflow#{invalid_suffix}. If this is known to be safe, the code can be run in " \
|
69
115
|
'a Temporalio::Workflow::Unsafe.illegal_call_tracing_disabled block.'
|
70
116
|
end
|
71
117
|
end
|
@@ -56,7 +56,8 @@ module Temporalio
|
|
56
56
|
raise ArgumentError, 'Activity must have schedule_to_close_timeout or start_to_close_timeout'
|
57
57
|
end
|
58
58
|
|
59
|
-
execute_activity_with_local_backoffs(local: false, cancellation: input.cancellation
|
59
|
+
execute_activity_with_local_backoffs(local: false, cancellation: input.cancellation,
|
60
|
+
result_hint: input.result_hint) do
|
60
61
|
seq = (@activity_counter += 1)
|
61
62
|
@instance.add_command(
|
62
63
|
Bridge::Api::WorkflowCommands::WorkflowCommand.new(
|
@@ -66,14 +67,17 @@ module Temporalio
|
|
66
67
|
activity_type: input.activity,
|
67
68
|
task_queue: input.task_queue,
|
68
69
|
headers: ProtoUtils.headers_to_proto_hash(input.headers, @instance.payload_converter),
|
69
|
-
arguments: ProtoUtils.convert_to_payload_array(
|
70
|
+
arguments: ProtoUtils.convert_to_payload_array(
|
71
|
+
@instance.payload_converter, input.args, hints: input.arg_hints
|
72
|
+
),
|
70
73
|
schedule_to_close_timeout: ProtoUtils.seconds_to_duration(input.schedule_to_close_timeout),
|
71
74
|
schedule_to_start_timeout: ProtoUtils.seconds_to_duration(input.schedule_to_start_timeout),
|
72
75
|
start_to_close_timeout: ProtoUtils.seconds_to_duration(input.start_to_close_timeout),
|
73
76
|
heartbeat_timeout: ProtoUtils.seconds_to_duration(input.heartbeat_timeout),
|
74
77
|
retry_policy: input.retry_policy&._to_proto,
|
75
78
|
cancellation_type: input.cancellation_type,
|
76
|
-
do_not_eagerly_execute: input.disable_eager_execution
|
79
|
+
do_not_eagerly_execute: input.disable_eager_execution,
|
80
|
+
priority: input.priority._to_proto
|
77
81
|
),
|
78
82
|
user_metadata: ProtoUtils.to_user_metadata(input.summary, nil, @instance.payload_converter)
|
79
83
|
)
|
@@ -87,7 +91,10 @@ module Temporalio
|
|
87
91
|
raise ArgumentError, 'Activity must have schedule_to_close_timeout or start_to_close_timeout'
|
88
92
|
end
|
89
93
|
|
90
|
-
|
94
|
+
@instance.assert_valid_local_activity.call(input.activity)
|
95
|
+
|
96
|
+
execute_activity_with_local_backoffs(local: true, cancellation: input.cancellation,
|
97
|
+
result_hint: input.result_hint) do |do_backoff|
|
91
98
|
seq = (@activity_counter += 1)
|
92
99
|
@instance.add_command(
|
93
100
|
Bridge::Api::WorkflowCommands::WorkflowCommand.new(
|
@@ -96,7 +103,9 @@ module Temporalio
|
|
96
103
|
activity_id: input.activity_id || seq.to_s,
|
97
104
|
activity_type: input.activity,
|
98
105
|
headers: ProtoUtils.headers_to_proto_hash(input.headers, @instance.payload_converter),
|
99
|
-
arguments: ProtoUtils.convert_to_payload_array(
|
106
|
+
arguments: ProtoUtils.convert_to_payload_array(
|
107
|
+
@instance.payload_converter, input.args, hints: input.arg_hints
|
108
|
+
),
|
100
109
|
schedule_to_close_timeout: ProtoUtils.seconds_to_duration(input.schedule_to_close_timeout),
|
101
110
|
schedule_to_start_timeout: ProtoUtils.seconds_to_duration(input.schedule_to_start_timeout),
|
102
111
|
start_to_close_timeout: ProtoUtils.seconds_to_duration(input.start_to_close_timeout),
|
@@ -112,7 +121,7 @@ module Temporalio
|
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
115
|
-
def execute_activity_with_local_backoffs(local:, cancellation:, &)
|
124
|
+
def execute_activity_with_local_backoffs(local:, cancellation:, result_hint:, &)
|
116
125
|
# We do not even want to schedule if the cancellation is already cancelled. We choose to use canceled
|
117
126
|
# failure instead of wrapping in activity failure which is similar to what other SDKs do, with the accepted
|
118
127
|
# tradeoff that it makes rescue more difficult (hence the presence of Error.canceled? helper).
|
@@ -121,7 +130,7 @@ module Temporalio
|
|
121
130
|
# This has to be done in a loop for local activity backoff
|
122
131
|
last_local_backoff = nil
|
123
132
|
loop do
|
124
|
-
result = execute_activity_once(local:, cancellation:, last_local_backoff:, &)
|
133
|
+
result = execute_activity_once(local:, cancellation:, last_local_backoff:, result_hint:, &)
|
125
134
|
return result unless result.is_a?(Bridge::Api::ActivityResult::DoBackoff)
|
126
135
|
|
127
136
|
# @type var result: untyped
|
@@ -133,7 +142,7 @@ module Temporalio
|
|
133
142
|
end
|
134
143
|
|
135
144
|
# If this doesn't raise, it returns success | DoBackoff
|
136
|
-
def execute_activity_once(local:, cancellation:, last_local_backoff:, &)
|
145
|
+
def execute_activity_once(local:, cancellation:, last_local_backoff:, result_hint:, &)
|
137
146
|
# Add to pending activities (removed by the resolver)
|
138
147
|
seq = yield last_local_backoff
|
139
148
|
@instance.pending_activities[seq] = Fiber.current
|
@@ -166,7 +175,7 @@ module Temporalio
|
|
166
175
|
|
167
176
|
case resolution.status
|
168
177
|
when :completed
|
169
|
-
@instance.payload_converter.from_payload(resolution.completed.result)
|
178
|
+
@instance.payload_converter.from_payload(resolution.completed.result, hint: result_hint)
|
170
179
|
when :failed
|
171
180
|
raise @instance.failure_converter.from_failure(resolution.failed.failure, @instance.payload_converter)
|
172
181
|
when :cancelled
|
@@ -190,6 +199,7 @@ module Temporalio
|
|
190
199
|
signal: input.signal,
|
191
200
|
args: input.args,
|
192
201
|
cancellation: input.cancellation,
|
202
|
+
arg_hints: input.arg_hints,
|
193
203
|
headers: input.headers
|
194
204
|
)
|
195
205
|
end
|
@@ -202,11 +212,12 @@ module Temporalio
|
|
202
212
|
signal: input.signal,
|
203
213
|
args: input.args,
|
204
214
|
cancellation: input.cancellation,
|
215
|
+
arg_hints: input.arg_hints,
|
205
216
|
headers: input.headers
|
206
217
|
)
|
207
218
|
end
|
208
219
|
|
209
|
-
def _signal_external_workflow(id:, run_id:, child:, signal:, args:, cancellation:, headers:)
|
220
|
+
def _signal_external_workflow(id:, run_id:, child:, signal:, args:, cancellation:, arg_hints:, headers:)
|
210
221
|
raise Error::CanceledError, 'Signal canceled before scheduled' if cancellation.canceled?
|
211
222
|
|
212
223
|
# Add command
|
@@ -214,7 +225,7 @@ module Temporalio
|
|
214
225
|
cmd = Bridge::Api::WorkflowCommands::SignalExternalWorkflowExecution.new(
|
215
226
|
seq:,
|
216
227
|
signal_name: signal,
|
217
|
-
args: ProtoUtils.convert_to_payload_array(@instance.payload_converter, args),
|
228
|
+
args: ProtoUtils.convert_to_payload_array(@instance.payload_converter, args, hints: arg_hints),
|
218
229
|
headers: ProtoUtils.headers_to_proto_hash(headers, @instance.payload_converter)
|
219
230
|
)
|
220
231
|
if child
|
@@ -324,7 +335,8 @@ module Temporalio
|
|
324
335
|
workflow_id: input.id,
|
325
336
|
workflow_type: input.workflow,
|
326
337
|
task_queue: input.task_queue,
|
327
|
-
input: ProtoUtils.convert_to_payload_array(@instance.payload_converter, input.args
|
338
|
+
input: ProtoUtils.convert_to_payload_array(@instance.payload_converter, input.args,
|
339
|
+
hints: input.arg_hints),
|
328
340
|
workflow_execution_timeout: ProtoUtils.seconds_to_duration(input.execution_timeout),
|
329
341
|
workflow_run_timeout: ProtoUtils.seconds_to_duration(input.run_timeout),
|
330
342
|
workflow_task_timeout: ProtoUtils.seconds_to_duration(input.task_timeout),
|
@@ -335,7 +347,8 @@ module Temporalio
|
|
335
347
|
headers: ProtoUtils.headers_to_proto_hash(input.headers, @instance.payload_converter),
|
336
348
|
memo: ProtoUtils.memo_to_proto_hash(input.memo, @instance.payload_converter),
|
337
349
|
search_attributes: input.search_attributes&._to_proto_hash,
|
338
|
-
cancellation_type: input.cancellation_type
|
350
|
+
cancellation_type: input.cancellation_type,
|
351
|
+
priority: input.priority._to_proto
|
339
352
|
),
|
340
353
|
user_metadata: ProtoUtils.to_user_metadata(
|
341
354
|
input.static_summary, input.static_details, @instance.payload_converter
|
@@ -370,7 +383,8 @@ module Temporalio
|
|
370
383
|
first_execution_run_id: resolution.succeeded.run_id,
|
371
384
|
instance: @instance,
|
372
385
|
cancellation: input.cancellation,
|
373
|
-
cancel_callback_key
|
386
|
+
cancel_callback_key:,
|
387
|
+
result_hint: input.result_hint
|
374
388
|
)
|
375
389
|
@instance.pending_child_workflows[seq] = handle
|
376
390
|
handle
|