temporalio 0.6.0 → 1.1.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/Cargo.lock +836 -1036
- data/Cargo.toml +6 -5
- data/Gemfile +3 -0
- data/README.md +2 -11
- data/ext/Cargo.toml +9 -8
- data/lib/temporalio/activity/info.rb +5 -0
- data/lib/temporalio/api/cloud/account/v1/message.rb +3 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +5 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +1 -1
- data/lib/temporalio/api/cloud/sink/v1/message.rb +3 -1
- data/lib/temporalio/api/deployment/v1/message.rb +1 -1
- data/lib/temporalio/api/namespace/v1/message.rb +1 -1
- data/lib/temporalio/api/payload_visitor.rb +6 -0
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +5 -1
- data/lib/temporalio/api/workflowservice/v1/service.rb +1 -1
- data/lib/temporalio/cancellation.rb +2 -2
- data/lib/temporalio/client/async_activity_handle.rb +1 -0
- data/lib/temporalio/client/connection/cloud_service.rb +30 -0
- data/lib/temporalio/client/connection/workflow_service.rb +30 -0
- data/lib/temporalio/client/connection.rb +14 -9
- data/lib/temporalio/client.rb +1 -1
- data/lib/temporalio/contrib/open_telemetry.rb +78 -25
- data/lib/temporalio/converters/payload_converter/composite.rb +1 -0
- data/lib/temporalio/converters/payload_converter/json_protobuf.rb +1 -1
- data/lib/temporalio/env_config.rb +343 -0
- data/lib/temporalio/error.rb +5 -1
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +1 -1
- data/lib/temporalio/internal/bridge/runtime.rb +1 -0
- data/lib/temporalio/internal/bridge/worker.rb +54 -3
- data/lib/temporalio/internal/client/implementation.rb +7 -2
- data/lib/temporalio/internal/worker/activity_worker.rb +1 -0
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +2 -0
- data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +17 -10
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +6 -5
- data/lib/temporalio/internal/worker/workflow_instance.rb +78 -80
- data/lib/temporalio/runtime.rb +16 -3
- data/lib/temporalio/testing/activity_environment.rb +1 -0
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/worker/interceptor.rb +1 -0
- data/lib/temporalio/worker/tuner.rb +183 -18
- data/lib/temporalio/worker/workflow_replayer.rb +4 -3
- data/lib/temporalio/worker.rb +4 -5
- data/lib/temporalio/workflow/info.rb +7 -0
- data/lib/temporalio/workflow.rb +6 -3
- metadata +2 -1
|
@@ -7,8 +7,6 @@ module Temporalio
|
|
|
7
7
|
module Bridge
|
|
8
8
|
class Worker
|
|
9
9
|
Options = Struct.new(
|
|
10
|
-
:activity,
|
|
11
|
-
:workflow,
|
|
12
10
|
:namespace,
|
|
13
11
|
:task_queue,
|
|
14
12
|
:tuner,
|
|
@@ -17,7 +15,10 @@ module Temporalio
|
|
|
17
15
|
:workflow_task_poller_behavior,
|
|
18
16
|
:nonsticky_to_sticky_poll_ratio,
|
|
19
17
|
:activity_task_poller_behavior,
|
|
20
|
-
:
|
|
18
|
+
:enable_workflows,
|
|
19
|
+
:enable_local_activities,
|
|
20
|
+
:enable_remote_activities,
|
|
21
|
+
:enable_nexus,
|
|
21
22
|
:sticky_queue_schedule_to_start_timeout,
|
|
22
23
|
:max_heartbeat_throttle_interval,
|
|
23
24
|
:default_heartbeat_throttle_interval,
|
|
@@ -40,6 +41,7 @@ module Temporalio
|
|
|
40
41
|
TunerSlotSupplierOptions = Struct.new(
|
|
41
42
|
:fixed_size,
|
|
42
43
|
:resource_based,
|
|
44
|
+
:custom,
|
|
43
45
|
keyword_init: true
|
|
44
46
|
)
|
|
45
47
|
|
|
@@ -103,6 +105,55 @@ module Temporalio
|
|
|
103
105
|
# TODO(cretz): Log error on this somehow?
|
|
104
106
|
async_complete_activity_task(proto.to_proto, queue)
|
|
105
107
|
end
|
|
108
|
+
|
|
109
|
+
class CustomSlotSupplier
|
|
110
|
+
def initialize(slot_supplier:, thread_pool:)
|
|
111
|
+
@slot_supplier = slot_supplier
|
|
112
|
+
@thread_pool = thread_pool
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def reserve_slot(context, cancellation, &block)
|
|
116
|
+
run_user_code do
|
|
117
|
+
@slot_supplier.reserve_slot(context, cancellation) { |v| block.call(v) }
|
|
118
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
119
|
+
block.call(e)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def try_reserve_slot(context, &block)
|
|
124
|
+
run_user_code do
|
|
125
|
+
block.call(@slot_supplier.try_reserve_slot(context))
|
|
126
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
127
|
+
block.call(e)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def mark_slot_used(context, &block)
|
|
132
|
+
run_user_code do
|
|
133
|
+
block.call(@slot_supplier.mark_slot_used(context))
|
|
134
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
135
|
+
block.call(e)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def release_slot(context, &block)
|
|
140
|
+
run_user_code do
|
|
141
|
+
block.call(@slot_supplier.release_slot(context))
|
|
142
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
143
|
+
block.call(e)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
private
|
|
148
|
+
|
|
149
|
+
def run_user_code(&)
|
|
150
|
+
if @thread_pool
|
|
151
|
+
@thread_pool.execute(&)
|
|
152
|
+
else
|
|
153
|
+
yield
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
106
157
|
end
|
|
107
158
|
end
|
|
108
159
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'google/protobuf/well_known_types'
|
|
4
4
|
require 'securerandom'
|
|
5
|
+
require 'temporalio/activity'
|
|
5
6
|
require 'temporalio/api'
|
|
6
7
|
require 'temporalio/client/activity_id_reference'
|
|
7
8
|
require 'temporalio/client/async_activity_handle'
|
|
@@ -829,9 +830,13 @@ module Temporalio
|
|
|
829
830
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
830
831
|
)
|
|
831
832
|
end
|
|
832
|
-
|
|
833
|
+
return unless resp.cancel_requested || resp.activity_paused || resp.activity_reset
|
|
833
834
|
|
|
834
|
-
|
|
835
|
+
raise Error::AsyncActivityCanceledError, Activity::CancellationDetails.new(
|
|
836
|
+
cancel_requested: resp.cancel_requested,
|
|
837
|
+
paused: resp.activity_paused,
|
|
838
|
+
reset: resp.activity_reset
|
|
839
|
+
)
|
|
835
840
|
end
|
|
836
841
|
|
|
837
842
|
def complete_async_activity(input)
|
|
@@ -185,6 +185,7 @@ module Temporalio
|
|
|
185
185
|
payloads = codec.decode(payloads) if codec
|
|
186
186
|
payloads.map { |p| Temporalio::Converters::RawValue.new(p) }
|
|
187
187
|
end,
|
|
188
|
+
retry_policy: (RetryPolicy._from_proto(start.retry_policy) if start.retry_policy),
|
|
188
189
|
schedule_to_close_timeout: Internal::ProtoUtils.duration_to_seconds(start.schedule_to_close_timeout),
|
|
189
190
|
scheduled_time: Internal::ProtoUtils.timestamp_to_time(start.scheduled_time) || raise, # Never nil
|
|
190
191
|
start_to_close_timeout: Internal::ProtoUtils.duration_to_seconds(start.start_to_close_timeout),
|
|
@@ -130,6 +130,7 @@ module Temporalio
|
|
|
130
130
|
def execute_local_activity(
|
|
131
131
|
activity,
|
|
132
132
|
*args,
|
|
133
|
+
summary:,
|
|
133
134
|
schedule_to_close_timeout:,
|
|
134
135
|
schedule_to_start_timeout:,
|
|
135
136
|
start_to_close_timeout:,
|
|
@@ -157,6 +158,7 @@ module Temporalio
|
|
|
157
158
|
Temporalio::Worker::Interceptor::Workflow::ExecuteLocalActivityInput.new(
|
|
158
159
|
activity:,
|
|
159
160
|
args:,
|
|
161
|
+
summary:,
|
|
160
162
|
schedule_to_close_timeout:,
|
|
161
163
|
schedule_to_start_timeout:,
|
|
162
164
|
start_to_close_timeout:,
|
|
@@ -84,7 +84,7 @@ module Temporalio
|
|
|
84
84
|
when :all
|
|
85
85
|
''
|
|
86
86
|
when Temporalio::Worker::IllegalWorkflowCallValidator
|
|
87
|
-
|
|
87
|
+
disable_temporarily do
|
|
88
88
|
vals.block.call(Temporalio::Worker::IllegalWorkflowCallValidator::CallInfo.new(
|
|
89
89
|
class_name:, method_name: tp.callee_id, trace_point: tp
|
|
90
90
|
))
|
|
@@ -98,7 +98,7 @@ module Temporalio
|
|
|
98
98
|
when true
|
|
99
99
|
''
|
|
100
100
|
when Temporalio::Worker::IllegalWorkflowCallValidator
|
|
101
|
-
|
|
101
|
+
disable_temporarily do
|
|
102
102
|
per_method.block.call(Temporalio::Worker::IllegalWorkflowCallValidator::CallInfo.new(
|
|
103
103
|
class_name:, method_name: tp.callee_id, trace_point: tp
|
|
104
104
|
))
|
|
@@ -118,8 +118,11 @@ module Temporalio
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
def enable(&block)
|
|
121
|
-
# We've seen leaking issues in Ruby 3.2 where
|
|
122
|
-
# that it was not started on. So we will check
|
|
121
|
+
# This is not reentrant and not expected to be called as such. We've seen leaking issues in Ruby 3.2 where
|
|
122
|
+
# the TracePoint inadvertently remains enabled even for threads that it was not started on. So we will check
|
|
123
|
+
# the thread ourselves. We also use the "enabled thread" concept for disabling checks too, see
|
|
124
|
+
# disable_temporarily for more details.
|
|
125
|
+
|
|
123
126
|
@enabled_thread = Thread.current
|
|
124
127
|
@tracepoint.enable do
|
|
125
128
|
block.call
|
|
@@ -128,13 +131,17 @@ module Temporalio
|
|
|
128
131
|
end
|
|
129
132
|
end
|
|
130
133
|
|
|
131
|
-
def
|
|
134
|
+
def disable_temporarily(&)
|
|
135
|
+
# An earlier version of this used @tracepoint.disable, but in some versions of Ruby, the observed behavior
|
|
136
|
+
# is confusingly not reentrant or at least not predictable. Therefore, instead of calling
|
|
137
|
+
# @tracepoint.disable, we are just unsetting the enabled thread. This means the tracer is still running, but
|
|
138
|
+
# no checks are performed. This is effectively a no-op if tracing was never enabled.
|
|
139
|
+
|
|
132
140
|
previous_thread = @enabled_thread
|
|
133
|
-
@
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
end
|
|
141
|
+
@enabled_thread = nil
|
|
142
|
+
yield
|
|
143
|
+
ensure
|
|
144
|
+
@enabled_thread = previous_thread
|
|
138
145
|
end
|
|
139
146
|
end
|
|
140
147
|
end
|
|
@@ -114,14 +114,15 @@ module Temporalio
|
|
|
114
114
|
local_retry_threshold: ProtoUtils.seconds_to_duration(input.local_retry_threshold),
|
|
115
115
|
attempt: do_backoff&.attempt || 0,
|
|
116
116
|
original_schedule_time: do_backoff&.original_schedule_time
|
|
117
|
-
)
|
|
117
|
+
),
|
|
118
|
+
user_metadata: ProtoUtils.to_user_metadata(input.summary, nil, @instance.payload_converter)
|
|
118
119
|
)
|
|
119
120
|
)
|
|
120
121
|
seq
|
|
121
122
|
end
|
|
122
123
|
end
|
|
123
124
|
|
|
124
|
-
def execute_activity_with_local_backoffs(local:, cancellation:, result_hint:, &)
|
|
125
|
+
def execute_activity_with_local_backoffs(local:, cancellation:, result_hint:, &block)
|
|
125
126
|
# We do not even want to schedule if the cancellation is already cancelled. We choose to use canceled
|
|
126
127
|
# failure instead of wrapping in activity failure which is similar to what other SDKs do, with the accepted
|
|
127
128
|
# tradeoff that it makes rescue more difficult (hence the presence of Error.canceled? helper).
|
|
@@ -130,7 +131,7 @@ module Temporalio
|
|
|
130
131
|
# This has to be done in a loop for local activity backoff
|
|
131
132
|
last_local_backoff = nil
|
|
132
133
|
loop do
|
|
133
|
-
result = execute_activity_once(local:, cancellation:, last_local_backoff:, result_hint:, &)
|
|
134
|
+
result = execute_activity_once(local:, cancellation:, last_local_backoff:, result_hint:, &block)
|
|
134
135
|
return result unless result.is_a?(Bridge::Api::ActivityResult::DoBackoff)
|
|
135
136
|
|
|
136
137
|
# @type var result: untyped
|
|
@@ -142,9 +143,9 @@ module Temporalio
|
|
|
142
143
|
end
|
|
143
144
|
|
|
144
145
|
# If this doesn't raise, it returns success | DoBackoff
|
|
145
|
-
def execute_activity_once(local:, cancellation:, last_local_backoff:, result_hint:, &)
|
|
146
|
+
def execute_activity_once(local:, cancellation:, last_local_backoff:, result_hint:, &block)
|
|
146
147
|
# Add to pending activities (removed by the resolver)
|
|
147
|
-
seq =
|
|
148
|
+
seq = block.call(last_local_backoff)
|
|
148
149
|
@instance.pending_activities[seq] = Fiber.current
|
|
149
150
|
|
|
150
151
|
# Add cancellation hook
|
|
@@ -125,6 +125,7 @@ module Temporalio
|
|
|
125
125
|
continued_run_id: ProtoUtils.string_or(@init_job.continued_from_execution_run_id),
|
|
126
126
|
cron_schedule: ProtoUtils.string_or(@init_job.cron_schedule),
|
|
127
127
|
execution_timeout: ProtoUtils.duration_to_seconds(@init_job.workflow_execution_timeout),
|
|
128
|
+
first_execution_run_id: @init_job.first_execution_run_id,
|
|
128
129
|
headers: ProtoUtils.headers_from_proto_map(@init_job.headers, @payload_converter) || {},
|
|
129
130
|
last_failure: if @init_job.continued_failure
|
|
130
131
|
@failure_converter.from_failure(@init_job.continued_failure, @payload_converter)
|
|
@@ -132,6 +133,7 @@ module Temporalio
|
|
|
132
133
|
last_result: if @init_job.last_completion_result
|
|
133
134
|
@payload_converter.from_payloads(@init_job.last_completion_result).first
|
|
134
135
|
end,
|
|
136
|
+
has_last_result?: !@init_job.last_completion_result.nil?,
|
|
135
137
|
namespace: details.namespace,
|
|
136
138
|
parent: if @init_job.parent_workflow_info
|
|
137
139
|
Workflow::Info::ParentInfo.new(
|
|
@@ -162,86 +164,9 @@ module Temporalio
|
|
|
162
164
|
end
|
|
163
165
|
|
|
164
166
|
def activate(activation)
|
|
165
|
-
# Run inside of scheduler
|
|
166
|
-
run_in_scheduler { activate_internal(activation) }
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
def add_command(command)
|
|
170
|
-
raise Workflow::InvalidWorkflowStateError, 'Cannot add commands in this context' if @context_frozen
|
|
171
|
-
|
|
172
|
-
@commands << command
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def instance
|
|
176
|
-
@instance or raise 'Instance accessed before created'
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def search_attributes
|
|
180
|
-
# Lazy on first access
|
|
181
|
-
@search_attributes ||= SearchAttributes._from_proto(
|
|
182
|
-
@init_job.search_attributes, disable_mutations: true, never_nil: true
|
|
183
|
-
) || raise
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def memo
|
|
187
|
-
# Lazy on first access
|
|
188
|
-
@memo ||= ExternallyImmutableHash.new(ProtoUtils.memo_from_proto(@init_job.memo, payload_converter) || {})
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def now
|
|
192
|
-
# Create each time
|
|
193
|
-
ProtoUtils.timestamp_to_time(@now_timestamp) or raise 'Time unexpectedly not present'
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def illegal_call_tracing_disabled(&)
|
|
197
|
-
@tracer.disable(&)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def patch(patch_id:, deprecated:)
|
|
201
|
-
# Use memoized result if present. If this is being deprecated, we can still use memoized result and skip the
|
|
202
|
-
# command.
|
|
203
|
-
patch_id = patch_id.to_s
|
|
204
|
-
@patches_memoized ||= {}
|
|
205
|
-
@patches_memoized.fetch(patch_id) do
|
|
206
|
-
patched = !replaying || @patches_notified.include?(patch_id)
|
|
207
|
-
@patches_memoized[patch_id] = patched
|
|
208
|
-
if patched
|
|
209
|
-
add_command(
|
|
210
|
-
Bridge::Api::WorkflowCommands::WorkflowCommand.new(
|
|
211
|
-
set_patch_marker: Bridge::Api::WorkflowCommands::SetPatchMarker.new(patch_id:, deprecated:)
|
|
212
|
-
)
|
|
213
|
-
)
|
|
214
|
-
end
|
|
215
|
-
patched
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
def metric_meter
|
|
220
|
-
@metric_meter ||= ReplaySafeMetric::Meter.new(
|
|
221
|
-
@runtime_metric_meter.with_additional_attributes(
|
|
222
|
-
{
|
|
223
|
-
namespace: info.namespace,
|
|
224
|
-
task_queue: info.task_queue,
|
|
225
|
-
workflow_type: info.workflow_type
|
|
226
|
-
}
|
|
227
|
-
)
|
|
228
|
-
)
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
private
|
|
232
|
-
|
|
233
|
-
def run_in_scheduler(&)
|
|
167
|
+
# Run inside of scheduler (removed on ensure)
|
|
234
168
|
Fiber.set_scheduler(@scheduler)
|
|
235
|
-
if @tracer
|
|
236
|
-
@tracer.enable(&)
|
|
237
|
-
else
|
|
238
|
-
yield
|
|
239
|
-
end
|
|
240
|
-
ensure
|
|
241
|
-
Fiber.set_scheduler(nil)
|
|
242
|
-
end
|
|
243
169
|
|
|
244
|
-
def activate_internal(activation)
|
|
245
170
|
# Reset some activation state
|
|
246
171
|
@commands = []
|
|
247
172
|
@current_activation_error = nil
|
|
@@ -266,8 +191,12 @@ module Temporalio
|
|
|
266
191
|
# the first activation)
|
|
267
192
|
@primary_fiber ||= schedule(top_level: true) { run_workflow }
|
|
268
193
|
|
|
269
|
-
# Run the event loop
|
|
270
|
-
@
|
|
194
|
+
# Run the event loop in the tracer if it exists
|
|
195
|
+
if @tracer
|
|
196
|
+
@tracer.enable { @scheduler.run_until_all_yielded }
|
|
197
|
+
else
|
|
198
|
+
@scheduler.run_until_all_yielded
|
|
199
|
+
end
|
|
271
200
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
272
201
|
on_top_level_exception(e)
|
|
273
202
|
end
|
|
@@ -306,8 +235,77 @@ module Temporalio
|
|
|
306
235
|
ensure
|
|
307
236
|
@commands = nil
|
|
308
237
|
@current_activation_error = nil
|
|
238
|
+
Fiber.set_scheduler(nil)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def add_command(command)
|
|
242
|
+
raise Workflow::InvalidWorkflowStateError, 'Cannot add commands in this context' if @context_frozen
|
|
243
|
+
|
|
244
|
+
@commands << command
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def instance
|
|
248
|
+
@instance or raise 'Instance accessed before created'
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def search_attributes
|
|
252
|
+
# Lazy on first access
|
|
253
|
+
@search_attributes ||= SearchAttributes._from_proto(
|
|
254
|
+
@init_job.search_attributes, disable_mutations: true, never_nil: true
|
|
255
|
+
) || raise
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def memo
|
|
259
|
+
# Lazy on first access
|
|
260
|
+
@memo ||= ExternallyImmutableHash.new(ProtoUtils.memo_from_proto(@init_job.memo, payload_converter) || {})
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def now
|
|
264
|
+
# Create each time
|
|
265
|
+
ProtoUtils.timestamp_to_time(@now_timestamp) or raise 'Time unexpectedly not present'
|
|
309
266
|
end
|
|
310
267
|
|
|
268
|
+
def illegal_call_tracing_disabled(&)
|
|
269
|
+
if @tracer
|
|
270
|
+
@tracer.disable_temporarily(&)
|
|
271
|
+
else
|
|
272
|
+
yield
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def patch(patch_id:, deprecated:)
|
|
277
|
+
# Use memoized result if present. If this is being deprecated, we can still use memoized result and skip the
|
|
278
|
+
# command.
|
|
279
|
+
patch_id = patch_id.to_s
|
|
280
|
+
@patches_memoized ||= {}
|
|
281
|
+
@patches_memoized.fetch(patch_id) do
|
|
282
|
+
patched = !replaying || @patches_notified.include?(patch_id)
|
|
283
|
+
@patches_memoized[patch_id] = patched
|
|
284
|
+
if patched
|
|
285
|
+
add_command(
|
|
286
|
+
Bridge::Api::WorkflowCommands::WorkflowCommand.new(
|
|
287
|
+
set_patch_marker: Bridge::Api::WorkflowCommands::SetPatchMarker.new(patch_id:, deprecated:)
|
|
288
|
+
)
|
|
289
|
+
)
|
|
290
|
+
end
|
|
291
|
+
patched
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def metric_meter
|
|
296
|
+
@metric_meter ||= ReplaySafeMetric::Meter.new(
|
|
297
|
+
@runtime_metric_meter.with_additional_attributes(
|
|
298
|
+
{
|
|
299
|
+
namespace: info.namespace,
|
|
300
|
+
task_queue: info.task_queue,
|
|
301
|
+
workflow_type: info.workflow_type
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
private
|
|
308
|
+
|
|
311
309
|
def create_instance
|
|
312
310
|
# Convert workflow arguments
|
|
313
311
|
@workflow_arguments = convert_args(payload_array: @init_job.arguments,
|
data/lib/temporalio/runtime.rb
CHANGED
|
@@ -101,7 +101,8 @@ module Temporalio
|
|
|
101
101
|
# @!visibility private
|
|
102
102
|
def _to_bridge
|
|
103
103
|
# @type self: LoggingFilterOptions
|
|
104
|
-
"#{other_level},
|
|
104
|
+
"#{other_level},temporalio_sdk_core=#{core_level},temporalio_client=#{core_level}," \
|
|
105
|
+
"temporalio_sdk=#{core_level},temporalio_bridge=#{core_level}"
|
|
105
106
|
end
|
|
106
107
|
end
|
|
107
108
|
|
|
@@ -329,12 +330,24 @@ module Temporalio
|
|
|
329
330
|
# pool, this also consumes a Ruby thread for its lifetime.
|
|
330
331
|
#
|
|
331
332
|
# @param telemetry [TelemetryOptions] Telemetry options to set.
|
|
332
|
-
|
|
333
|
+
# @param worker_heartbeat_interval [Float, nil] Interval for worker heartbeats in seconds. Can be nil to disable
|
|
334
|
+
# heartbeating. Interval must be between 1s and 60s.
|
|
335
|
+
def initialize(
|
|
336
|
+
telemetry: TelemetryOptions.new,
|
|
337
|
+
worker_heartbeat_interval: 60
|
|
338
|
+
)
|
|
339
|
+
if !worker_heartbeat_interval.nil? && !worker_heartbeat_interval.positive?
|
|
340
|
+
raise 'Worker heartbeat interval must be positive'
|
|
341
|
+
end
|
|
342
|
+
|
|
333
343
|
# Set runtime on the buffer which will fail if the buffer is used on another runtime
|
|
334
344
|
telemetry.metrics&.buffer&._set_runtime(self)
|
|
335
345
|
|
|
336
346
|
@core_runtime = Internal::Bridge::Runtime.new(
|
|
337
|
-
Internal::Bridge::Runtime::Options.new(
|
|
347
|
+
Internal::Bridge::Runtime::Options.new(
|
|
348
|
+
telemetry: telemetry._to_bridge,
|
|
349
|
+
worker_heartbeat_interval:
|
|
350
|
+
)
|
|
338
351
|
)
|
|
339
352
|
@metric_meter = Internal::Metric::Meter.create_from_runtime(self) || Metric::Meter.null
|
|
340
353
|
# We need a thread to run the command loop
|
data/lib/temporalio/version.rb
CHANGED