temporalio 0.6.0-aarch64-linux → 1.1.0-aarch64-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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/lib/temporalio/activity/info.rb +5 -0
  4. data/lib/temporalio/api/cloud/account/v1/message.rb +3 -1
  5. data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +5 -1
  6. data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +1 -1
  7. data/lib/temporalio/api/cloud/sink/v1/message.rb +3 -1
  8. data/lib/temporalio/api/deployment/v1/message.rb +1 -1
  9. data/lib/temporalio/api/namespace/v1/message.rb +1 -1
  10. data/lib/temporalio/api/payload_visitor.rb +6 -0
  11. data/lib/temporalio/api/workflowservice/v1/request_response.rb +5 -1
  12. data/lib/temporalio/api/workflowservice/v1/service.rb +1 -1
  13. data/lib/temporalio/cancellation.rb +2 -2
  14. data/lib/temporalio/client/async_activity_handle.rb +1 -0
  15. data/lib/temporalio/client/connection/cloud_service.rb +30 -0
  16. data/lib/temporalio/client/connection/workflow_service.rb +30 -0
  17. data/lib/temporalio/client/connection.rb +14 -9
  18. data/lib/temporalio/client.rb +1 -1
  19. data/lib/temporalio/contrib/open_telemetry.rb +78 -25
  20. data/lib/temporalio/converters/payload_converter/composite.rb +1 -0
  21. data/lib/temporalio/converters/payload_converter/json_protobuf.rb +1 -1
  22. data/lib/temporalio/env_config.rb +343 -0
  23. data/lib/temporalio/error.rb +5 -1
  24. data/lib/temporalio/internal/bridge/3.2/temporalio_bridge.so +0 -0
  25. data/lib/temporalio/internal/bridge/3.3/temporalio_bridge.so +0 -0
  26. data/lib/temporalio/internal/bridge/3.4/temporalio_bridge.so +0 -0
  27. data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +1 -1
  28. data/lib/temporalio/internal/bridge/runtime.rb +1 -0
  29. data/lib/temporalio/internal/bridge/worker.rb +54 -3
  30. data/lib/temporalio/internal/client/implementation.rb +7 -2
  31. data/lib/temporalio/internal/worker/activity_worker.rb +1 -0
  32. data/lib/temporalio/internal/worker/workflow_instance/context.rb +2 -0
  33. data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +17 -10
  34. data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +6 -5
  35. data/lib/temporalio/internal/worker/workflow_instance.rb +78 -80
  36. data/lib/temporalio/runtime.rb +16 -3
  37. data/lib/temporalio/testing/activity_environment.rb +1 -0
  38. data/lib/temporalio/version.rb +1 -1
  39. data/lib/temporalio/worker/interceptor.rb +1 -0
  40. data/lib/temporalio/worker/tuner.rb +183 -18
  41. data/lib/temporalio/worker/workflow_replayer.rb +4 -3
  42. data/lib/temporalio/worker.rb +4 -5
  43. data/lib/temporalio/workflow/info.rb +7 -0
  44. data/lib/temporalio/workflow.rb +6 -3
  45. metadata +3 -2
@@ -22,21 +22,20 @@ module Temporalio
22
22
  end
23
23
 
24
24
  # @!visibility private
25
- def _to_bridge_options
25
+ def _to_bridge_options(_tuner)
26
26
  Internal::Bridge::Worker::TunerSlotSupplierOptions.new(
27
27
  fixed_size: slots,
28
- resource_based: nil
28
+ resource_based: nil,
29
+ custom: nil
29
30
  )
30
31
  end
31
32
  end
32
33
 
33
34
  # A slot supplier that will dynamically adjust the number of slots based on resource usage.
34
- #
35
- # @note WARNING: This API is experimental.
36
35
  class ResourceBased < SlotSupplier
37
36
  attr_reader :tuner_options, :slot_options
38
37
 
39
- # Create a reosurce-based slot supplier.
38
+ # Create a resource-based slot supplier.
40
39
  #
41
40
  # @param tuner_options [ResourceBasedTunerOptions] General tuner options.
42
41
  # @param slot_options [ResourceBasedSlotOptions] Slot-supplier-specific tuner options.
@@ -46,7 +45,7 @@ module Temporalio
46
45
  end
47
46
 
48
47
  # @!visibility private
49
- def _to_bridge_options
48
+ def _to_bridge_options(_tuner)
50
49
  Internal::Bridge::Worker::TunerSlotSupplierOptions.new(
51
50
  fixed_size: nil,
52
51
  resource_based: Internal::Bridge::Worker::TunerResourceBasedSlotSupplierOptions.new(
@@ -55,14 +54,173 @@ module Temporalio
55
54
  min_slots: slot_options.min_slots,
56
55
  max_slots: slot_options.max_slots,
57
56
  ramp_throttle: slot_options.ramp_throttle
57
+ ),
58
+ custom: nil
59
+ )
60
+ end
61
+ end
62
+
63
+ # A slot supplier that has callbacks invoked to handle slot supplying.
64
+ #
65
+ # Users should be cautious when implementing this and make sure it is heavily tested and the documentation for
66
+ # every method is well understood.
67
+ class Custom < SlotSupplier
68
+ # Context provided for slot reservation on custom slot supplier.
69
+ #
70
+ # @!attribute slot_type
71
+ # @return [:workflow, :activity, :local_activity, :nexus] Slot type.
72
+ # @!attribute task_queue
73
+ # @return [String] Task queue.
74
+ # @!attribute worker_identity
75
+ # @return [String] Worker identity.
76
+ # @!attribute worker_deployment_name
77
+ # @return [String] Worker deployment name or empty string if not applicable.
78
+ # @!attribute worker_build_id
79
+ # @return [String] Worker build ID or empty string if not applicable.
80
+ # @!attribute sticky?
81
+ # @return [Boolean] True if this reservation is for a sticky workflow task.
82
+ ReserveContext = Data.define(
83
+ :slot_type,
84
+ :task_queue,
85
+ :worker_identity,
86
+ :worker_deployment_name,
87
+ :worker_build_id,
88
+ :sticky?
89
+ )
90
+
91
+ # Context provided for marking a slot used.
92
+ #
93
+ # @!attribute slot_info
94
+ # @return [SlotInfo::Workflow, SlotInfo::Activity, SlotInfo::LocalActivity, SlotInfo::Nexus] Information
95
+ # about the slot. This is never nil.
96
+ # @!attribute permit
97
+ # @return [Object] Object that was provided as the permit on reserve.
98
+ MarkUsedContext = Data.define(
99
+ :slot_info,
100
+ :permit
101
+ )
102
+
103
+ # Context provided for releasing a slot.
104
+ #
105
+ # @!attribute slot_info
106
+ # @return [SlotInfo::Workflow, SlotInfo::Activity, SlotInfo::LocalActivity, SlotInfo::Nexus, nil]
107
+ # Information about the slot. This may be nil if the slot was never used.
108
+ # @!attribute permit
109
+ # @return [Object] Object that was provided as the permit on reserve.
110
+ ReleaseContext = Data.define(
111
+ :slot_info,
112
+ :permit
113
+ )
114
+
115
+ # Reserve a slot.
116
+ #
117
+ # This can/should block and must provide the permit to the (code) block. The permit is any object (including
118
+ # nil) that will be given on the context for mark_slot_used and release_slot.
119
+ #
120
+ # Just returning from this call is not enough to reserve the slot, a permit must be provided to the block
121
+ # (e.g. via yield or block.call). If the call completes, the system will still wait on the block (so this can
122
+ # be backgrounded by passing the block to something else). Reservations may be canceled via the given
123
+ # cancellation. Users can do things like add_cancel_callback, but it is very important that the code in the
124
+ # callback is fast as it is run on the same reactor thread as many other Temporal Ruby worker calls.
125
+ #
126
+ # @note WARNING: This call should never raise an exception. Any exception raised is ignored and this is called
127
+ # again after 1 second.
128
+ #
129
+ # @param context [ReserveContext] Contextual information about this reserve call.
130
+ # @param cancellation [Cancellation] Cancellation that is canceled when the reservation is no longer being
131
+ # asked for.
132
+ # @yield [Object] Confirm reservation and provide a permit.
133
+ def reserve_slot(context, cancellation, &)
134
+ raise NotImplementedError
135
+ end
136
+
137
+ # Try to reserve a slot.
138
+ #
139
+ # @note WARNING: This should never block, this should return immediately with a permit, or nil if the
140
+ # reservation could not occur.
141
+ #
142
+ # @note WARNING: This call should never raise an exception. Any exception raised is ignored and the slot
143
+ # reservation attempt fails (i.e. same as if this method returned nil).
144
+ #
145
+ # @param context [ReserveContext] Contextual information about this reserve call.
146
+ # @return [Object, nil] A non-nil object to perform the reservation successfully, a nil to fail the
147
+ # reservation.
148
+ def try_reserve_slot(context)
149
+ raise NotImplementedError
150
+ end
151
+
152
+ # Mark a slot as used.
153
+ #
154
+ # Due to the nature of Temporal polling, slots are reserved before they are used and may never get used. This
155
+ # call is made as just a notification when a slot is actually used.
156
+ #
157
+ # @note WARNING: This should never block, this should return immediately.
158
+ #
159
+ # @note WARNING: This call should never raise an exception. Any exception raised is ignored.
160
+ #
161
+ # @param context [MarkUsedContext] Contextual information about this reserve call.
162
+ def mark_slot_used(context)
163
+ raise NotImplementedError
164
+ end
165
+
166
+ # Release a previously reserved slot.
167
+ #
168
+ # @note WARNING: This should never block, this should return immediately.
169
+ #
170
+ # @note WARNING: This call should never raise an exception. Any exception raised is ignored.
171
+ #
172
+ # @param context [ReleaseContext] Contextual information about this reserve call.
173
+ def release_slot(context)
174
+ raise NotImplementedError
175
+ end
176
+
177
+ # @!visibility private
178
+ def _to_bridge_options(tuner)
179
+ Internal::Bridge::Worker::TunerSlotSupplierOptions.new(
180
+ fixed_size: nil,
181
+ resource_based: nil,
182
+ custom: Internal::Bridge::Worker::CustomSlotSupplier.new(
183
+ slot_supplier: self,
184
+ thread_pool: tuner.custom_slot_supplier_thread_pool
58
185
  )
59
186
  )
60
187
  end
188
+
189
+ # Slot information.
190
+ module SlotInfo
191
+ # Information about a workflow slot.
192
+ #
193
+ # @!attribute workflow_type
194
+ # @return [String] Workflow type.
195
+ # @!attribute sticky?
196
+ # @return [Boolean] Whether the slot was for a sticky task.
197
+ Workflow = Data.define(:workflow_type, :sticky?)
198
+
199
+ # Information about an activity slot.
200
+ #
201
+ # @!attribute activity_type
202
+ # @return [String] Activity type.
203
+ Activity = Data.define(:activity_type)
204
+
205
+ # Information about a local activity slot.
206
+ #
207
+ # @!attribute activity_type
208
+ # @return [String] Activity type.
209
+ LocalActivity = Data.define(:activity_type)
210
+
211
+ # Information about a Nexus slot.
212
+ #
213
+ # @!attribute service
214
+ # @return [String] Nexus service.
215
+ # @!attribute operation
216
+ # @return [String] Nexus operation.
217
+ Nexus = Data.define(:service, :operation)
218
+ end
61
219
  end
62
220
 
63
221
  # @!visibility private
64
- def _to_bridge_options
65
- raise ArgumentError, 'Tuner slot suppliers must be instances of Fixed or ResourceBased'
222
+ def _to_bridge_options(_tuner)
223
+ raise ArgumentError, 'Tuner slot suppliers must be instances of Fixed, ResourceBased, or Custom'
66
224
  end
67
225
  end
68
226
 
@@ -75,10 +233,9 @@ module Temporalio
75
233
  # @!attribute target_cpu_usage
76
234
  # @return [Float] A value between 0 and 1 that represents the target (system) CPU usage. This can be set to 1.0
77
235
  # if desired, but it's recommended to leave some headroom for other processes.
78
- ResourceBasedTunerOptions = Struct.new(
236
+ ResourceBasedTunerOptions = Data.define(
79
237
  :target_memory_usage,
80
- :target_cpu_usage,
81
- keyword_init: true
238
+ :target_cpu_usage
82
239
  )
83
240
 
84
241
  # Options for a specific slot type being used with {SlotSupplier::ResourceBased}.
@@ -94,11 +251,10 @@ module Temporalio
94
251
  #
95
252
  # This value matters because how many resources a task will use cannot be determined ahead of time, and thus
96
253
  # the system should wait to see how much resources are used before issuing more slots.
97
- ResourceBasedSlotOptions = Struct.new(
254
+ ResourceBasedSlotOptions = Data.define(
98
255
  :min_slots,
99
256
  :max_slots,
100
- :ramp_throttle,
101
- keyword_init: true
257
+ :ramp_throttle
102
258
  )
103
259
 
104
260
  # Create a fixed-size tuner with the provided number of slots.
@@ -161,27 +317,36 @@ module Temporalio
161
317
  # @return [SlotSupplier] Slot supplier for local activities.
162
318
  attr_reader :local_activity_slot_supplier
163
319
 
320
+ # @return [ThreadPool, nil] Thread pool for custom slot suppliers.
321
+ attr_reader :custom_slot_supplier_thread_pool
322
+
164
323
  # Create a tuner from 3 slot suppliers.
165
324
  #
166
325
  # @param workflow_slot_supplier [SlotSupplier] Slot supplier for workflows.
167
326
  # @param activity_slot_supplier [SlotSupplier] Slot supplier for activities.
168
327
  # @param local_activity_slot_supplier [SlotSupplier] Slot supplier for local activities.
328
+ # @param custom_slot_supplier_thread_pool [ThreadPool, nil] Thread pool to make all custom slot supplier calls on.
329
+ # If there are no custom slot suppliers, this parameter is ignored. Technically users may set this to nil which
330
+ # will not use a thread pool to make slot supplier calls, but that is dangerous and not advised because even the
331
+ # slightest blocking call can slow down the system.
169
332
  def initialize(
170
333
  workflow_slot_supplier:,
171
334
  activity_slot_supplier:,
172
- local_activity_slot_supplier:
335
+ local_activity_slot_supplier:,
336
+ custom_slot_supplier_thread_pool: ThreadPool.default
173
337
  )
174
338
  @workflow_slot_supplier = workflow_slot_supplier
175
339
  @activity_slot_supplier = activity_slot_supplier
176
340
  @local_activity_slot_supplier = local_activity_slot_supplier
341
+ @custom_slot_supplier_thread_pool = custom_slot_supplier_thread_pool
177
342
  end
178
343
 
179
344
  # @!visibility private
180
345
  def _to_bridge_options
181
346
  Internal::Bridge::Worker::TunerOptions.new(
182
- workflow_slot_supplier: workflow_slot_supplier._to_bridge_options,
183
- activity_slot_supplier: activity_slot_supplier._to_bridge_options,
184
- local_activity_slot_supplier: local_activity_slot_supplier._to_bridge_options
347
+ workflow_slot_supplier: workflow_slot_supplier._to_bridge_options(self),
348
+ activity_slot_supplier: activity_slot_supplier._to_bridge_options(self),
349
+ local_activity_slot_supplier: local_activity_slot_supplier._to_bridge_options(self)
185
350
  )
186
351
  end
187
352
  end
@@ -197,8 +197,6 @@ module Temporalio
197
197
  @bridge_replayer, @bridge_worker = Internal::Bridge::Worker::WorkflowReplayer.new(
198
198
  options.runtime._core_runtime,
199
199
  Internal::Bridge::Worker::Options.new(
200
- activity: false,
201
- workflow: true,
202
200
  namespace: options.namespace,
203
201
  task_queue: options.task_queue,
204
202
  tuner: Tuner.create_fixed(
@@ -211,7 +209,10 @@ module Temporalio
211
209
  nonsticky_to_sticky_poll_ratio: 1.0,
212
210
  activity_task_poller_behavior:
213
211
  Temporalio::Worker::PollerBehavior::SimpleMaximum.new(1)._to_bridge_options,
214
- no_remote_activities: true,
212
+ enable_workflows: true,
213
+ enable_local_activities: false,
214
+ enable_remote_activities: false,
215
+ enable_nexus: false,
215
216
  sticky_queue_schedule_to_start_timeout: 1.0,
216
217
  max_heartbeat_throttle_interval: 1.0,
217
218
  default_heartbeat_throttle_interval: 1.0,
@@ -465,8 +465,6 @@ module Temporalio
465
465
  @bridge_worker = Internal::Bridge::Worker.new(
466
466
  client.connection._core_client,
467
467
  Internal::Bridge::Worker::Options.new(
468
- activity: !activities.empty?,
469
- workflow: !workflows.empty?,
470
468
  namespace: client.namespace,
471
469
  task_queue:,
472
470
  tuner: tuner._to_bridge_options,
@@ -475,9 +473,10 @@ module Temporalio
475
473
  workflow_task_poller_behavior: workflow_task_poller_behavior._to_bridge_options,
476
474
  nonsticky_to_sticky_poll_ratio:,
477
475
  activity_task_poller_behavior: activity_task_poller_behavior._to_bridge_options,
478
- # For shutdown to work properly, we must disable remote activities
479
- # ourselves if there are no activities
480
- no_remote_activities: no_remote_activities || activities.empty?,
476
+ enable_workflows: !workflows.empty?,
477
+ enable_local_activities: !workflows.empty? && !activities.empty?,
478
+ enable_remote_activities: !activities.empty? && !no_remote_activities,
479
+ enable_nexus: false,
481
480
  sticky_queue_schedule_to_start_timeout:,
482
481
  max_heartbeat_throttle_interval:,
483
482
  default_heartbeat_throttle_interval:,
@@ -7,9 +7,11 @@ module Temporalio
7
7
  :continued_run_id,
8
8
  :cron_schedule,
9
9
  :execution_timeout,
10
+ :first_execution_run_id,
10
11
  :headers,
11
12
  :last_failure,
12
13
  :last_result,
14
+ :has_last_result?,
13
15
  :namespace,
14
16
  :parent,
15
17
  :priority,
@@ -35,12 +37,17 @@ module Temporalio
35
37
  # @return [String, nil] Cron schedule if applicable.
36
38
  # @!attribute execution_timeout
37
39
  # @return [Float, nil] Execution timeout for the workflow.
40
+ # @!attribute first_execution_run_id
41
+ # @return [String] The very first run ID the workflow ever had, following continuation chains.
38
42
  # @!attribute headers
39
43
  # @return [Hash<String, Api::Common::V1::Payload>] Headers.
40
44
  # @!attribute last_failure
41
45
  # @return [Exception, nil] Failure if this workflow run is a continuation of a failure.
42
46
  # @!attribute last_result
43
47
  # @return [Object, nil] Successful result if this workflow is a continuation of a success.
48
+ # @!attribute has_last_result?
49
+ # @return [Boolean] Successful result if this workflow is a continuation of a success.
50
+
44
51
  # @!attribute namespace
45
52
  # @return [String] Namespace for the workflow.
46
53
  # @!attribute parent
@@ -208,14 +208,16 @@ module Temporalio
208
208
  #
209
209
  # @param activity [Class<Activity::Definition>, Symbol, String] Activity definition class or name.
210
210
  # @param args [Array<Object>] Arguments to the activity.
211
+ # @param summary [String, nil] Single-line summary for this activity that may appear in CLI/UI. This can be in
212
+ # single-line Temporal markdown format. This is currently experimental.
211
213
  # @param schedule_to_close_timeout [Float, nil] Max amount of time the activity can take from first being scheduled
212
214
  # to being completed before it times out. This is inclusive of all retries.
213
215
  # @param schedule_to_start_timeout [Float, nil] Max amount of time the activity can take to be started from first
214
216
  # being scheduled.
215
217
  # @param start_to_close_timeout [Float, nil] Max amount of time a single activity run can take from when it starts
216
218
  # to when it completes. This is per retry.
217
- # @param retry_policy [RetryPolicy] How an activity is retried on failure. If unset, a server-defined default is
218
- # used. Set maximum attempts to 1 to disable retries.
219
+ # @param retry_policy [RetryPolicy, nil] How an activity is retried on failure. If unset, a default policy is used.
220
+ # Set maximum attempts to 1 to disable retries.
219
221
  # @param local_retry_threshold [Float, nil] If the activity is retrying and backoff would exceed this value, a timer
220
222
  # is scheduled and the activity is retried after. Otherwise, backoff will happen internally within the task.
221
223
  # Defaults to 1 minute.
@@ -238,6 +240,7 @@ module Temporalio
238
240
  def self.execute_local_activity(
239
241
  activity,
240
242
  *args,
243
+ summary: nil,
241
244
  schedule_to_close_timeout: nil,
242
245
  schedule_to_start_timeout: nil,
243
246
  start_to_close_timeout: nil,
@@ -251,7 +254,7 @@ module Temporalio
251
254
  )
252
255
  _current.execute_local_activity(
253
256
  activity, *args,
254
- schedule_to_close_timeout:, schedule_to_start_timeout:, start_to_close_timeout:,
257
+ summary:, schedule_to_close_timeout:, schedule_to_start_timeout:, start_to_close_timeout:,
255
258
  retry_policy:, local_retry_threshold:, cancellation:, cancellation_type:,
256
259
  activity_id:, arg_hints:, result_hint:
257
260
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temporalio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.1.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Temporal Technologies Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-25 00:00:00.000000000 Z
11
+ date: 2025-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -156,6 +156,7 @@ files:
156
156
  - lib/temporalio/converters/payload_converter/json_plain.rb
157
157
  - lib/temporalio/converters/payload_converter/json_protobuf.rb
158
158
  - lib/temporalio/converters/raw_value.rb
159
+ - lib/temporalio/env_config.rb
159
160
  - lib/temporalio/error.rb
160
161
  - lib/temporalio/error/failure.rb
161
162
  - lib/temporalio/internal.rb