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
data/lib/temporalio/workflow.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'random/formatter'
|
4
4
|
require 'temporalio/error'
|
5
|
+
require 'temporalio/priority'
|
5
6
|
require 'temporalio/workflow/activity_cancellation_type'
|
6
7
|
require 'temporalio/workflow/child_workflow_cancellation_type'
|
7
8
|
require 'temporalio/workflow/child_workflow_handle'
|
@@ -38,6 +39,36 @@ module Temporalio
|
|
38
39
|
_current.continue_as_new_suggested
|
39
40
|
end
|
40
41
|
|
42
|
+
# Get current details for this workflow that may appear in UI/CLI. Unlike static details set at start, this value
|
43
|
+
# can be updated throughout the life of the workflow. This can be in Temporal markdown format and can span multiple
|
44
|
+
# lines. This is currently experimental.
|
45
|
+
#
|
46
|
+
# @return [String] Current details. Default is empty string.
|
47
|
+
def self.current_details
|
48
|
+
_current.current_details
|
49
|
+
end
|
50
|
+
|
51
|
+
# Set current details for this workflow that may appear in UI/CLI. Unlike static details set at start, this value
|
52
|
+
# can be updated throughout the life of the workflow. This can be in Temporal markdown format and can span multiple
|
53
|
+
# lines. This is currently experimental.
|
54
|
+
#
|
55
|
+
# @param details [String] Current details. Can use empty string to unset.
|
56
|
+
def self.current_details=(details)
|
57
|
+
_current.current_details = details
|
58
|
+
end
|
59
|
+
|
60
|
+
# Get the deployment version of the worker which executed the current Workflow Task.
|
61
|
+
#
|
62
|
+
# May be nil if the task was completed by a worker without a deployment version or build id. If
|
63
|
+
# this worker is the one executing this task for the first time and has a deployment version
|
64
|
+
# set, then its ID will be used. This value may change over the lifetime of the workflow run,
|
65
|
+
# but is deterministic and safe to use for branching. This is currently experimental.
|
66
|
+
#
|
67
|
+
# @return [WorkerDeploymentVersion, nil] the current deployment version if any.
|
68
|
+
def self.current_deployment_version
|
69
|
+
_current.current_deployment_version
|
70
|
+
end
|
71
|
+
|
41
72
|
# @return [Integer] Current number of events in history. This value is the current history event count up until the
|
42
73
|
# current task. Note, this value may not be up to date when accessed in a query.
|
43
74
|
def self.current_history_length
|
@@ -77,6 +108,8 @@ module Temporalio
|
|
77
108
|
# @param activity [Class<Activity::Definition>, Symbol, String] Activity definition class or activity name.
|
78
109
|
# @param args [Array<Object>] Arguments to the activity.
|
79
110
|
# @param task_queue [String] Task queue to run the activity on. Defaults to the current workflow's task queue.
|
111
|
+
# @param summary [String, nil] Single-line summary for this activity that may appear in CLI/UI. This can be in
|
112
|
+
# single-line Temporal markdown format. This is currently experimental.
|
80
113
|
# @param schedule_to_close_timeout [Float, nil] Max amount of time the activity can take from first being scheduled
|
81
114
|
# to being completed before it times out. This is inclusive of all retries.
|
82
115
|
# @param schedule_to_start_timeout [Float, nil] Max amount of time the activity can take to be started from first
|
@@ -98,6 +131,11 @@ module Temporalio
|
|
98
131
|
# optimization on some servers that sends activities back to the same worker as the calling workflow if they can
|
99
132
|
# run there. If `false` (the default), eager execution may still be disabled at the worker level or may not be
|
100
133
|
# requested due to lack of available slots.
|
134
|
+
# @param priority [Priority] Priority of the activity. This is currently experimental.
|
135
|
+
# @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
|
136
|
+
# activity definition has arg hints, those are used by default.
|
137
|
+
# @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the activity
|
138
|
+
# definition has result hint, it is used by default.
|
101
139
|
#
|
102
140
|
# @return [Object] Result of the activity.
|
103
141
|
# @raise [Error::ActivityError] Activity failed (and retry was disabled or exhausted).
|
@@ -107,6 +145,7 @@ module Temporalio
|
|
107
145
|
activity,
|
108
146
|
*args,
|
109
147
|
task_queue: info.task_queue,
|
148
|
+
summary: nil,
|
110
149
|
schedule_to_close_timeout: nil,
|
111
150
|
schedule_to_start_timeout: nil,
|
112
151
|
start_to_close_timeout: nil,
|
@@ -115,12 +154,16 @@ module Temporalio
|
|
115
154
|
cancellation: Workflow.cancellation,
|
116
155
|
cancellation_type: ActivityCancellationType::TRY_CANCEL,
|
117
156
|
activity_id: nil,
|
118
|
-
disable_eager_execution: false
|
157
|
+
disable_eager_execution: false,
|
158
|
+
priority: Priority.default,
|
159
|
+
arg_hints: nil,
|
160
|
+
result_hint: nil
|
119
161
|
)
|
120
162
|
_current.execute_activity(
|
121
163
|
activity, *args,
|
122
|
-
task_queue:, schedule_to_close_timeout:, schedule_to_start_timeout:, start_to_close_timeout:,
|
123
|
-
heartbeat_timeout:, retry_policy:, cancellation:, cancellation_type:, activity_id:, disable_eager_execution
|
164
|
+
task_queue:, summary:, schedule_to_close_timeout:, schedule_to_start_timeout:, start_to_close_timeout:,
|
165
|
+
heartbeat_timeout:, retry_policy:, cancellation:, cancellation_type:, activity_id:, disable_eager_execution:,
|
166
|
+
priority:, arg_hints:, result_hint:
|
124
167
|
)
|
125
168
|
end
|
126
169
|
|
@@ -130,6 +173,8 @@ module Temporalio
|
|
130
173
|
*args,
|
131
174
|
id: random.uuid,
|
132
175
|
task_queue: info.task_queue,
|
176
|
+
static_summary: nil,
|
177
|
+
static_details: nil,
|
133
178
|
cancellation: Workflow.cancellation,
|
134
179
|
cancellation_type: ChildWorkflowCancellationType::WAIT_CANCELLATION_COMPLETED,
|
135
180
|
parent_close_policy: ParentClosePolicy::TERMINATE,
|
@@ -140,12 +185,16 @@ module Temporalio
|
|
140
185
|
retry_policy: nil,
|
141
186
|
cron_schedule: nil,
|
142
187
|
memo: nil,
|
143
|
-
search_attributes: nil
|
188
|
+
search_attributes: nil,
|
189
|
+
priority: Priority.default,
|
190
|
+
arg_hints: nil,
|
191
|
+
result_hint: nil
|
144
192
|
)
|
145
193
|
start_child_workflow(
|
146
194
|
workflow, *args,
|
147
|
-
id:, task_queue:,
|
148
|
-
|
195
|
+
id:, task_queue:, static_summary:, static_details:, cancellation:, cancellation_type:,
|
196
|
+
parent_close_policy:, execution_timeout:, run_timeout:, task_timeout:, id_reuse_policy:,
|
197
|
+
retry_policy:, cron_schedule:, memo:, search_attributes:, priority:, arg_hints:, result_hint:
|
149
198
|
).result
|
150
199
|
end
|
151
200
|
|
@@ -176,6 +225,10 @@ module Temporalio
|
|
176
225
|
# workflow.
|
177
226
|
# @param activity_id [String, nil] Optional unique identifier for the activity. This is an advanced setting that
|
178
227
|
# should not be set unless users are sure they need to. Contact Temporal before setting this value.
|
228
|
+
# @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
|
229
|
+
# activity definition has arg hints, those are used by default.
|
230
|
+
# @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the activity
|
231
|
+
# definition has result hint, it is used by default.
|
179
232
|
#
|
180
233
|
# @return [Object] Result of the activity.
|
181
234
|
# @raise [Error::ActivityError] Activity failed (and retry was disabled or exhausted).
|
@@ -191,12 +244,15 @@ module Temporalio
|
|
191
244
|
local_retry_threshold: nil,
|
192
245
|
cancellation: Workflow.cancellation,
|
193
246
|
cancellation_type: ActivityCancellationType::TRY_CANCEL,
|
194
|
-
activity_id: nil
|
247
|
+
activity_id: nil,
|
248
|
+
arg_hints: nil,
|
249
|
+
result_hint: nil
|
195
250
|
)
|
196
251
|
_current.execute_local_activity(
|
197
252
|
activity, *args,
|
198
253
|
schedule_to_close_timeout:, schedule_to_start_timeout:, start_to_close_timeout:,
|
199
|
-
retry_policy:, local_retry_threshold:, cancellation:, cancellation_type:,
|
254
|
+
retry_policy:, local_retry_threshold:, cancellation:, cancellation_type:,
|
255
|
+
activity_id:, arg_hints:, result_hint:
|
200
256
|
)
|
201
257
|
end
|
202
258
|
|
@@ -220,6 +276,12 @@ module Temporalio
|
|
220
276
|
_current.info
|
221
277
|
end
|
222
278
|
|
279
|
+
# @return [Definition, nil] Workflow class instance. This should always be present except in
|
280
|
+
# {Worker::Interceptor::Workflow::Inbound.init} where it will be nil.
|
281
|
+
def self.instance
|
282
|
+
_current.instance
|
283
|
+
end
|
284
|
+
|
223
285
|
# @return [Logger] Logger for the workflow. This is a scoped logger that automatically appends workflow details to
|
224
286
|
# every log and takes care not to log during replay.
|
225
287
|
def self.logger
|
@@ -298,7 +360,7 @@ module Temporalio
|
|
298
360
|
# value cannot be negative. Since Temporal timers are server-side, timer resolution may not end up as precise as
|
299
361
|
# system timers.
|
300
362
|
# @param summary [String, nil] A simple string identifying this timer that may be visible in UI/CLI. While it can be
|
301
|
-
# normal text, it is best to treat as a timer ID.
|
363
|
+
# normal text, it is best to treat as a timer ID. This is currently experimental.
|
302
364
|
# @param cancellation [Cancellation] Cancellation for this timer.
|
303
365
|
# @raise [Error::CanceledError] Sleep canceled.
|
304
366
|
def self.sleep(duration, summary: nil, cancellation: Workflow.cancellation)
|
@@ -311,6 +373,12 @@ module Temporalio
|
|
311
373
|
# @param args [Array<Object>] Arguments to the workflow.
|
312
374
|
# @param id [String] Unique identifier for the workflow execution. Defaults to a new UUID from {random}.
|
313
375
|
# @param task_queue [String] Task queue to run the workflow on. Defaults to the current workflow's task queue.
|
376
|
+
# @param static_summary [String, nil] Fixed single-line summary for this workflow execution that may appear in
|
377
|
+
# CLI/UI. This can be in single-line Temporal markdown format. This is currently experimental.
|
378
|
+
# @param static_details [String, nil] Fixed details for this workflow execution that may appear in CLI/UI. This can
|
379
|
+
# be in Temporal markdown format and can be multiple lines. This is a fixed value on the workflow that cannot be
|
380
|
+
# updated. For details that can be updated, use {Workflow.current_details=} within the workflow. This is currently
|
381
|
+
# experimental.
|
314
382
|
# @param cancellation [Cancellation] Cancellation to apply to the child workflow. How cancellation is treated is
|
315
383
|
# based on `cancellation_type`. This defaults to the workflow's cancellation.
|
316
384
|
# @param cancellation_type [ChildWorkflowCancellationType] How the child workflow will react to cancellation.
|
@@ -324,6 +392,11 @@ module Temporalio
|
|
324
392
|
# @param cron_schedule [String, nil] Cron schedule. Users should use schedules instead of this.
|
325
393
|
# @param memo [Hash{String, Symbol => Object}, nil] Memo for the workflow.
|
326
394
|
# @param search_attributes [SearchAttributes, nil] Search attributes for the workflow.
|
395
|
+
# @param priority [Priority] Priority of the workflow. This is currently experimental.
|
396
|
+
# @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
|
397
|
+
# workflow definition has arg hints, those are used by default.
|
398
|
+
# @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the workflow
|
399
|
+
# definition has result hint, it is used by default.
|
327
400
|
#
|
328
401
|
# @return [ChildWorkflowHandle] Workflow handle to the started workflow.
|
329
402
|
# @raise [Error::WorkflowAlreadyStartedError] Workflow already exists for the ID.
|
@@ -333,6 +406,8 @@ module Temporalio
|
|
333
406
|
*args,
|
334
407
|
id: random.uuid,
|
335
408
|
task_queue: info.task_queue,
|
409
|
+
static_summary: nil,
|
410
|
+
static_details: nil,
|
336
411
|
cancellation: Workflow.cancellation,
|
337
412
|
cancellation_type: ChildWorkflowCancellationType::WAIT_CANCELLATION_COMPLETED,
|
338
413
|
parent_close_policy: ParentClosePolicy::TERMINATE,
|
@@ -343,15 +418,25 @@ module Temporalio
|
|
343
418
|
retry_policy: nil,
|
344
419
|
cron_schedule: nil,
|
345
420
|
memo: nil,
|
346
|
-
search_attributes: nil
|
421
|
+
search_attributes: nil,
|
422
|
+
priority: Priority.default,
|
423
|
+
arg_hints: nil,
|
424
|
+
result_hint: nil
|
347
425
|
)
|
348
426
|
_current.start_child_workflow(
|
349
427
|
workflow, *args,
|
350
|
-
id:, task_queue:,
|
351
|
-
|
428
|
+
id:, task_queue:, static_summary:, static_details:, cancellation:, cancellation_type:,
|
429
|
+
parent_close_policy:, execution_timeout:, run_timeout:, task_timeout:, id_reuse_policy:,
|
430
|
+
retry_policy:, cron_schedule:, memo:, search_attributes:, priority:, arg_hints:, result_hint:
|
352
431
|
)
|
353
432
|
end
|
354
433
|
|
434
|
+
# @return [Hash<Object, Object>] General in-workflow storage. Most users will store state on the workflow class
|
435
|
+
# instance instead, this is only for utilities without access to the class instance.
|
436
|
+
def self.storage
|
437
|
+
_current.storage
|
438
|
+
end
|
439
|
+
|
355
440
|
# Run the block until the timeout is reached. This is backed by {sleep}. This does not accept cancellation because
|
356
441
|
# it is expected the block within will properly handle/bubble cancellation.
|
357
442
|
#
|
@@ -361,8 +446,8 @@ module Temporalio
|
|
361
446
|
# exception.
|
362
447
|
# @param message [String] Message to use for timeout exception. Defaults to "execution expired" like
|
363
448
|
# {::Timeout.timeout}.
|
364
|
-
# @param summary [String] Timer
|
365
|
-
# method for details.
|
449
|
+
# @param summary [String] Timer summary for the timer created by this timeout. This is backed by {sleep} so see that
|
450
|
+
# method for details. This is currently experimental.
|
366
451
|
#
|
367
452
|
# @yield Block to run with a timeout.
|
368
453
|
# @return [Object] The result of the block.
|
@@ -458,12 +543,27 @@ module Temporalio
|
|
458
543
|
def self.illegal_call_tracing_disabled(&)
|
459
544
|
Workflow._current.illegal_call_tracing_disabled(&)
|
460
545
|
end
|
546
|
+
|
547
|
+
# Run a block of code with IO enabled. Specifically this allows the `io_wait` call of the fiber scheduler to work.
|
548
|
+
# Users should be cautious about using this as it can often signify unsafe code. Note, this is often only
|
549
|
+
# applicable to network code as file IO and most process-based IO does not go through scheduler `io_wait`.
|
550
|
+
def self.io_enabled(&)
|
551
|
+
Workflow._current.io_enabled(&)
|
552
|
+
end
|
553
|
+
|
554
|
+
# Run a block of code with the durable/deterministic workflow Fiber scheduler off. This means fallback to default
|
555
|
+
# fiber scheduler and no workflow helpers will be available in the block. This is usually only needed in advanced
|
556
|
+
# situations where a third party library does something like use "Timeout" in a way that shouldn't be made
|
557
|
+
# durable.
|
558
|
+
def self.durable_scheduler_disabled(&)
|
559
|
+
Workflow._current.durable_scheduler_disabled(&)
|
560
|
+
end
|
461
561
|
end
|
462
562
|
|
463
563
|
# Error that is raised by a workflow out of the primary workflow method to issue a continue-as-new.
|
464
564
|
class ContinueAsNewError < Error
|
465
565
|
attr_accessor :args, :workflow, :task_queue, :run_timeout, :task_timeout,
|
466
|
-
:retry_policy, :memo, :search_attributes, :headers
|
566
|
+
:retry_policy, :memo, :search_attributes, :arg_hints, :headers
|
467
567
|
|
468
568
|
# Create a continue as new error.
|
469
569
|
#
|
@@ -482,6 +582,8 @@ module Temporalio
|
|
482
582
|
# is used.
|
483
583
|
# @param search_attributes [SearchAttributes, nil] Search attributes for the workflow. If unset/nil, the current
|
484
584
|
# workflow search attributes are used.
|
585
|
+
# @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
|
586
|
+
# workflow definition has arg hints, those are used by default.
|
485
587
|
# @param headers [Hash<String, Object>] Headers for the workflow. The default is _not_ carried over from the
|
486
588
|
# current workflow.
|
487
589
|
def initialize(
|
@@ -493,6 +595,7 @@ module Temporalio
|
|
493
595
|
retry_policy: nil,
|
494
596
|
memo: nil,
|
495
597
|
search_attributes: nil,
|
598
|
+
arg_hints: nil,
|
496
599
|
headers: {}
|
497
600
|
)
|
498
601
|
super('Continue as new')
|
@@ -504,6 +607,7 @@ module Temporalio
|
|
504
607
|
@retry_policy = retry_policy
|
505
608
|
@memo = memo
|
506
609
|
@search_attributes = search_attributes
|
610
|
+
@arg_hints = arg_hints
|
507
611
|
@headers = headers
|
508
612
|
Workflow._current.initialize_continue_as_new_error(self)
|
509
613
|
end
|
@@ -1,9 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'temporalio/api'
|
4
|
+
|
3
5
|
module Temporalio
|
4
6
|
# Representation of a workflow's history.
|
5
7
|
class WorkflowHistory
|
6
|
-
#
|
8
|
+
# Convert a JSON string to workflow history. This supports the JSON format exported by Temporal UI and CLI.
|
9
|
+
#
|
10
|
+
# @param json [String] JSON string.
|
11
|
+
# @return [WorkflowHistory] Converted history.
|
12
|
+
def self.from_history_json(json)
|
13
|
+
WorkflowHistory.new(Api::History::V1::History.decode_json(json).events.to_a)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Array<Api::History::V1::HistoryEvent>] History events for the workflow.
|
7
17
|
attr_reader :events
|
8
18
|
|
9
19
|
# @!visibility private
|
@@ -18,5 +28,20 @@ module Temporalio
|
|
18
28
|
|
19
29
|
start.workflow_id
|
20
30
|
end
|
31
|
+
|
32
|
+
# Convert to history JSON.
|
33
|
+
#
|
34
|
+
# @return [String] JSON string.
|
35
|
+
def to_history_json
|
36
|
+
Api::History::V1::History.encode_json(Api::History::V1::History.new(events:))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Compare history.
|
40
|
+
#
|
41
|
+
# @param other [WorkflowHistory] Other history.
|
42
|
+
# @return [Boolean] True if equal.
|
43
|
+
def ==(other)
|
44
|
+
other.is_a?(WorkflowHistory) && events == other.events
|
45
|
+
end
|
21
46
|
end
|
22
47
|
end
|
data/lib/temporalio.rb
CHANGED
data/temporalio.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
spec.extensions = ['ext/Cargo.toml']
|
25
25
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
26
|
+
spec.required_ruby_version = '>= 3.2.0'
|
26
27
|
|
27
|
-
spec.add_dependency 'google-protobuf', '>= 3.
|
28
|
+
spec.add_dependency 'google-protobuf', '>= 3.25.0'
|
29
|
+
spec.add_dependency 'logger'
|
28
30
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: temporalio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Temporal Technologies Inc
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: google-protobuf
|
@@ -15,14 +15,28 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 3.
|
18
|
+
version: 3.25.0
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 3.
|
25
|
+
version: 3.25.0
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: logger
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
26
40
|
email:
|
27
41
|
- sdk@temporal.io
|
28
42
|
executables: []
|
@@ -40,6 +54,7 @@ files:
|
|
40
54
|
- ext/Cargo.toml
|
41
55
|
- lib/temporalio.rb
|
42
56
|
- lib/temporalio/activity.rb
|
57
|
+
- lib/temporalio/activity/cancellation_details.rb
|
43
58
|
- lib/temporalio/activity/complete_async_error.rb
|
44
59
|
- lib/temporalio/activity/context.rb
|
45
60
|
- lib/temporalio/activity/definition.rb
|
@@ -62,12 +77,15 @@ files:
|
|
62
77
|
- lib/temporalio/api/command/v1/message.rb
|
63
78
|
- lib/temporalio/api/common/v1/grpc_status.rb
|
64
79
|
- lib/temporalio/api/common/v1/message.rb
|
80
|
+
- lib/temporalio/api/deployment/v1/message.rb
|
65
81
|
- lib/temporalio/api/enums/v1/batch_operation.rb
|
66
82
|
- lib/temporalio/api/enums/v1/command_type.rb
|
67
83
|
- lib/temporalio/api/enums/v1/common.rb
|
84
|
+
- lib/temporalio/api/enums/v1/deployment.rb
|
68
85
|
- lib/temporalio/api/enums/v1/event_type.rb
|
69
86
|
- lib/temporalio/api/enums/v1/failed_cause.rb
|
70
87
|
- lib/temporalio/api/enums/v1/namespace.rb
|
88
|
+
- lib/temporalio/api/enums/v1/nexus.rb
|
71
89
|
- lib/temporalio/api/enums/v1/query.rb
|
72
90
|
- lib/temporalio/api/enums/v1/reset.rb
|
73
91
|
- lib/temporalio/api/enums/v1/schedule.rb
|
@@ -88,6 +106,7 @@ files:
|
|
88
106
|
- lib/temporalio/api/protocol/v1/message.rb
|
89
107
|
- lib/temporalio/api/query/v1/message.rb
|
90
108
|
- lib/temporalio/api/replication/v1/message.rb
|
109
|
+
- lib/temporalio/api/rules/v1/message.rb
|
91
110
|
- lib/temporalio/api/schedule/v1/message.rb
|
92
111
|
- lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb
|
93
112
|
- lib/temporalio/api/sdk/v1/task_complete_metadata.rb
|
@@ -98,6 +117,7 @@ files:
|
|
98
117
|
- lib/temporalio/api/testservice/v1/service.rb
|
99
118
|
- lib/temporalio/api/update/v1/message.rb
|
100
119
|
- lib/temporalio/api/version/v1/message.rb
|
120
|
+
- lib/temporalio/api/worker/v1/message.rb
|
101
121
|
- lib/temporalio/api/workflow/v1/message.rb
|
102
122
|
- lib/temporalio/api/workflowservice.rb
|
103
123
|
- lib/temporalio/api/workflowservice/v1/request_response.rb
|
@@ -115,6 +135,7 @@ files:
|
|
115
135
|
- lib/temporalio/client/interceptor.rb
|
116
136
|
- lib/temporalio/client/schedule.rb
|
117
137
|
- lib/temporalio/client/schedule_handle.rb
|
138
|
+
- lib/temporalio/client/with_start_workflow_operation.rb
|
118
139
|
- lib/temporalio/client/workflow_execution.rb
|
119
140
|
- lib/temporalio/client/workflow_execution_count.rb
|
120
141
|
- lib/temporalio/client/workflow_execution_status.rb
|
@@ -123,6 +144,7 @@ files:
|
|
123
144
|
- lib/temporalio/client/workflow_update_handle.rb
|
124
145
|
- lib/temporalio/client/workflow_update_wait_stage.rb
|
125
146
|
- lib/temporalio/common_enums.rb
|
147
|
+
- lib/temporalio/contrib/open_telemetry.rb
|
126
148
|
- lib/temporalio/converters.rb
|
127
149
|
- lib/temporalio/converters/data_converter.rb
|
128
150
|
- lib/temporalio/converters/failure_converter.rb
|
@@ -176,23 +198,31 @@ files:
|
|
176
198
|
- lib/temporalio/internal/worker/workflow_instance/scheduler.rb
|
177
199
|
- lib/temporalio/internal/worker/workflow_worker.rb
|
178
200
|
- lib/temporalio/metric.rb
|
201
|
+
- lib/temporalio/priority.rb
|
179
202
|
- lib/temporalio/retry_policy.rb
|
180
203
|
- lib/temporalio/runtime.rb
|
204
|
+
- lib/temporalio/runtime/metric_buffer.rb
|
181
205
|
- lib/temporalio/scoped_logger.rb
|
182
206
|
- lib/temporalio/search_attributes.rb
|
183
207
|
- lib/temporalio/testing.rb
|
184
208
|
- lib/temporalio/testing/activity_environment.rb
|
185
209
|
- lib/temporalio/testing/workflow_environment.rb
|
186
210
|
- lib/temporalio/version.rb
|
211
|
+
- lib/temporalio/versioning_override.rb
|
187
212
|
- lib/temporalio/worker.rb
|
188
213
|
- lib/temporalio/worker/activity_executor.rb
|
189
214
|
- lib/temporalio/worker/activity_executor/fiber.rb
|
190
215
|
- lib/temporalio/worker/activity_executor/thread_pool.rb
|
216
|
+
- lib/temporalio/worker/deployment_options.rb
|
217
|
+
- lib/temporalio/worker/illegal_workflow_call_validator.rb
|
191
218
|
- lib/temporalio/worker/interceptor.rb
|
219
|
+
- lib/temporalio/worker/poller_behavior.rb
|
192
220
|
- lib/temporalio/worker/thread_pool.rb
|
193
221
|
- lib/temporalio/worker/tuner.rb
|
194
222
|
- lib/temporalio/worker/workflow_executor.rb
|
195
223
|
- lib/temporalio/worker/workflow_executor/thread_pool.rb
|
224
|
+
- lib/temporalio/worker/workflow_replayer.rb
|
225
|
+
- lib/temporalio/worker_deployment_version.rb
|
196
226
|
- lib/temporalio/workflow.rb
|
197
227
|
- lib/temporalio/workflow/activity_cancellation_type.rb
|
198
228
|
- lib/temporalio/workflow/child_workflow_cancellation_type.rb
|
@@ -220,14 +250,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
250
|
requirements:
|
221
251
|
- - ">="
|
222
252
|
- !ruby/object:Gem::Version
|
223
|
-
version:
|
253
|
+
version: 3.2.0
|
224
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
255
|
requirements:
|
226
256
|
- - ">="
|
227
257
|
- !ruby/object:Gem::Version
|
228
258
|
version: '0'
|
229
259
|
requirements: []
|
230
|
-
rubygems_version: 3.6.
|
260
|
+
rubygems_version: 3.6.9
|
231
261
|
specification_version: 4
|
232
262
|
summary: Temporal.io Ruby SDK
|
233
263
|
test_files: []
|