temporalio 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/Cargo.lock +659 -370
- data/Cargo.toml +2 -2
- data/Gemfile +3 -3
- data/README.md +589 -47
- data/Rakefile +10 -296
- data/ext/Cargo.toml +1 -0
- data/lib/temporalio/activity/complete_async_error.rb +1 -1
- data/lib/temporalio/activity/context.rb +5 -2
- data/lib/temporalio/activity/definition.rb +163 -65
- data/lib/temporalio/activity/info.rb +22 -21
- data/lib/temporalio/activity.rb +2 -59
- data/lib/temporalio/api/activity/v1/message.rb +25 -0
- data/lib/temporalio/api/cloud/account/v1/message.rb +28 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +34 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +1 -1
- data/lib/temporalio/api/cloud/identity/v1/message.rb +6 -1
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +8 -1
- data/lib/temporalio/api/cloud/nexus/v1/message.rb +31 -0
- data/lib/temporalio/api/cloud/operation/v1/message.rb +2 -1
- data/lib/temporalio/api/cloud/region/v1/message.rb +2 -1
- data/lib/temporalio/api/cloud/resource/v1/message.rb +23 -0
- data/lib/temporalio/api/cloud/sink/v1/message.rb +24 -0
- data/lib/temporalio/api/cloud/usage/v1/message.rb +31 -0
- data/lib/temporalio/api/common/v1/message.rb +7 -1
- data/lib/temporalio/api/enums/v1/event_type.rb +1 -1
- data/lib/temporalio/api/enums/v1/failed_cause.rb +1 -1
- data/lib/temporalio/api/enums/v1/reset.rb +1 -1
- data/lib/temporalio/api/history/v1/message.rb +1 -1
- data/lib/temporalio/api/nexus/v1/message.rb +2 -2
- data/lib/temporalio/api/operatorservice/v1/service.rb +1 -1
- data/lib/temporalio/api/payload_visitor.rb +1513 -0
- data/lib/temporalio/api/schedule/v1/message.rb +2 -1
- data/lib/temporalio/api/testservice/v1/request_response.rb +31 -0
- data/lib/temporalio/api/testservice/v1/service.rb +23 -0
- data/lib/temporalio/api/workflow/v1/message.rb +1 -1
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +17 -2
- data/lib/temporalio/api/workflowservice/v1/service.rb +1 -1
- data/lib/temporalio/api.rb +1 -0
- data/lib/temporalio/cancellation.rb +34 -14
- data/lib/temporalio/client/async_activity_handle.rb +12 -37
- data/lib/temporalio/client/connection/cloud_service.rb +309 -231
- data/lib/temporalio/client/connection/operator_service.rb +36 -84
- data/lib/temporalio/client/connection/service.rb +6 -5
- data/lib/temporalio/client/connection/test_service.rb +111 -0
- data/lib/temporalio/client/connection/workflow_service.rb +264 -441
- data/lib/temporalio/client/connection.rb +90 -44
- data/lib/temporalio/client/interceptor.rb +160 -60
- data/lib/temporalio/client/schedule.rb +967 -0
- data/lib/temporalio/client/schedule_handle.rb +126 -0
- data/lib/temporalio/client/workflow_execution.rb +7 -10
- data/lib/temporalio/client/workflow_handle.rb +38 -95
- data/lib/temporalio/client/workflow_update_handle.rb +3 -5
- data/lib/temporalio/client.rb +122 -42
- data/lib/temporalio/common_enums.rb +17 -0
- data/lib/temporalio/converters/data_converter.rb +4 -7
- data/lib/temporalio/converters/failure_converter.rb +5 -3
- data/lib/temporalio/converters/payload_converter/composite.rb +4 -0
- data/lib/temporalio/converters/payload_converter.rb +6 -8
- data/lib/temporalio/converters/raw_value.rb +20 -0
- data/lib/temporalio/error/failure.rb +1 -1
- data/lib/temporalio/error.rb +10 -2
- data/lib/temporalio/internal/bridge/api/core_interface.rb +5 -1
- data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +33 -0
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +5 -1
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +4 -1
- data/lib/temporalio/internal/bridge/client.rb +11 -6
- data/lib/temporalio/internal/bridge/testing.rb +20 -0
- data/lib/temporalio/internal/bridge/worker.rb +2 -0
- data/lib/temporalio/internal/bridge.rb +1 -1
- data/lib/temporalio/internal/client/implementation.rb +245 -70
- data/lib/temporalio/internal/metric.rb +122 -0
- data/lib/temporalio/internal/proto_utils.rb +86 -7
- data/lib/temporalio/internal/worker/activity_worker.rb +52 -24
- data/lib/temporalio/internal/worker/multi_runner.rb +51 -7
- data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +54 -0
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +329 -0
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +44 -0
- data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +32 -0
- data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +22 -0
- data/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb +25 -0
- data/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb +41 -0
- data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +97 -0
- data/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb +62 -0
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +415 -0
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +37 -0
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb +40 -0
- data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +163 -0
- data/lib/temporalio/internal/worker/workflow_instance.rb +730 -0
- data/lib/temporalio/internal/worker/workflow_worker.rb +196 -0
- data/lib/temporalio/metric.rb +109 -0
- data/lib/temporalio/retry_policy.rb +37 -14
- data/lib/temporalio/runtime.rb +118 -75
- data/lib/temporalio/search_attributes.rb +80 -37
- data/lib/temporalio/testing/activity_environment.rb +2 -2
- data/lib/temporalio/testing/workflow_environment.rb +251 -5
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/worker/activity_executor/thread_pool.rb +9 -217
- data/lib/temporalio/worker/activity_executor.rb +3 -3
- data/lib/temporalio/worker/interceptor.rb +340 -66
- data/lib/temporalio/worker/thread_pool.rb +237 -0
- data/lib/temporalio/worker/workflow_executor/thread_pool.rb +230 -0
- data/lib/temporalio/worker/workflow_executor.rb +26 -0
- data/lib/temporalio/worker.rb +201 -30
- data/lib/temporalio/workflow/activity_cancellation_type.rb +20 -0
- data/lib/temporalio/workflow/child_workflow_cancellation_type.rb +21 -0
- data/lib/temporalio/workflow/child_workflow_handle.rb +43 -0
- data/lib/temporalio/workflow/definition.rb +566 -0
- data/lib/temporalio/workflow/external_workflow_handle.rb +41 -0
- data/lib/temporalio/workflow/future.rb +151 -0
- data/lib/temporalio/workflow/handler_unfinished_policy.rb +13 -0
- data/lib/temporalio/workflow/info.rb +82 -0
- data/lib/temporalio/workflow/parent_close_policy.rb +19 -0
- data/lib/temporalio/workflow/update_info.rb +20 -0
- data/lib/temporalio/workflow.rb +523 -0
- data/lib/temporalio.rb +4 -0
- data/temporalio.gemspec +2 -2
- metadata +50 -8
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/client/interceptor'
|
4
|
+
require 'temporalio/client/schedule'
|
5
|
+
|
6
|
+
module Temporalio
|
7
|
+
class Client
|
8
|
+
# Handle for interacting with a schedule. This is usually created via {Client.create_schedule} or
|
9
|
+
# {Client.schedule_handle}.
|
10
|
+
class ScheduleHandle
|
11
|
+
# @return [String] ID of the schedule.
|
12
|
+
attr_reader :id
|
13
|
+
|
14
|
+
# @!visibility private
|
15
|
+
def initialize(client:, id:)
|
16
|
+
@client = client
|
17
|
+
@id = id
|
18
|
+
end
|
19
|
+
|
20
|
+
# Backfill the schedule by going through the specified time periods as if they passed right now.
|
21
|
+
#
|
22
|
+
# @param backfills [Array<Schedule::Backfill>] Backfill periods.
|
23
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
24
|
+
#
|
25
|
+
# @raise [Error::RPCError] RPC error from call.
|
26
|
+
def backfill(
|
27
|
+
*backfills,
|
28
|
+
rpc_options: nil
|
29
|
+
)
|
30
|
+
raise ArgumentError, 'At least one backfill required' if backfills.empty?
|
31
|
+
|
32
|
+
@client._impl.backfill_schedule(Interceptor::BackfillScheduleInput.new(
|
33
|
+
id:,
|
34
|
+
backfills:,
|
35
|
+
rpc_options:
|
36
|
+
))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Delete this schedule.
|
40
|
+
#
|
41
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
42
|
+
#
|
43
|
+
# @raise [Error::RPCError] RPC error from call.
|
44
|
+
def delete(rpc_options: nil)
|
45
|
+
@client._impl.delete_schedule(Interceptor::DeleteScheduleInput.new(
|
46
|
+
id:,
|
47
|
+
rpc_options:
|
48
|
+
))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Fetch this schedule's description.
|
52
|
+
#
|
53
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
54
|
+
#
|
55
|
+
# @return [Schedule::Description] Schedule description.
|
56
|
+
# @raise [Error::RPCError] RPC error from call.
|
57
|
+
def describe(rpc_options: nil)
|
58
|
+
@client._impl.describe_schedule(Interceptor::DescribeScheduleInput.new(
|
59
|
+
id:,
|
60
|
+
rpc_options:
|
61
|
+
))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Pause the schedule and set a note.
|
65
|
+
#
|
66
|
+
# @param note [String] Note to set on the schedule.
|
67
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
68
|
+
#
|
69
|
+
# @raise [Error::RPCError] RPC error from call.
|
70
|
+
def pause(note: 'Paused via Ruby SDK', rpc_options: nil)
|
71
|
+
@client._impl.pause_schedule(Interceptor::PauseScheduleInput.new(
|
72
|
+
id:,
|
73
|
+
note:,
|
74
|
+
rpc_options:
|
75
|
+
))
|
76
|
+
end
|
77
|
+
|
78
|
+
# Trigger an action on this schedule to happen immediately.
|
79
|
+
#
|
80
|
+
# @param overlap [Schedule::OverlapPolicy, nil] If set, overrides the schedule's overlap policy.
|
81
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
82
|
+
#
|
83
|
+
# @raise [Error::RPCError] RPC error from call.
|
84
|
+
def trigger(overlap: nil, rpc_options: nil)
|
85
|
+
@client._impl.trigger_schedule(Interceptor::TriggerScheduleInput.new(
|
86
|
+
id:,
|
87
|
+
overlap:,
|
88
|
+
rpc_options:
|
89
|
+
))
|
90
|
+
end
|
91
|
+
|
92
|
+
# Unpause the schedule and set a note.
|
93
|
+
#
|
94
|
+
# @param note [String] Note to set on the schedule.
|
95
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
96
|
+
#
|
97
|
+
# @raise [Error::RPCError] RPC error from call.
|
98
|
+
def unpause(note: 'Unpaused via Ruby SDK', rpc_options: nil)
|
99
|
+
@client._impl.unpause_schedule(Interceptor::UnpauseScheduleInput.new(
|
100
|
+
id:,
|
101
|
+
note:,
|
102
|
+
rpc_options:
|
103
|
+
))
|
104
|
+
end
|
105
|
+
|
106
|
+
# Update a schedule using a callback to build the update from the description.
|
107
|
+
#
|
108
|
+
# NOTE: In future versions, the callback may be invoked multiple times in a conflict-resolution loop.
|
109
|
+
#
|
110
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
111
|
+
# @yield Block called to obtain the update.
|
112
|
+
# @yieldparam [Schedule::Update::Input] Parameter to the block that contains a description with the schedule to be
|
113
|
+
# updated.
|
114
|
+
# @yieldreturn [Schedule::Update, nil] The update to apply, or `nil` to not perform an update.
|
115
|
+
#
|
116
|
+
# @raise [Error::RPCError] RPC error from call.
|
117
|
+
def update(rpc_options: nil, &updater)
|
118
|
+
@client._impl.update_schedule(Interceptor::UpdateScheduleInput.new(
|
119
|
+
id:,
|
120
|
+
updater:,
|
121
|
+
rpc_options:
|
122
|
+
))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -15,17 +15,18 @@ module Temporalio
|
|
15
15
|
# @!visibility private
|
16
16
|
def initialize(raw_info, data_converter)
|
17
17
|
@raw_info = raw_info
|
18
|
-
@
|
18
|
+
@memo = Internal::ProtoUtils::LazyMemo.new(raw_info.memo, data_converter)
|
19
|
+
@search_attributes = Internal::ProtoUtils::LazySearchAttributes.new(raw_info.search_attributes)
|
19
20
|
end
|
20
21
|
|
21
22
|
# @return [Time, nil] When the workflow was closed if closed.
|
22
23
|
def close_time
|
23
|
-
@raw_info.close_time
|
24
|
+
Internal::ProtoUtils.timestamp_to_time(@raw_info.close_time)
|
24
25
|
end
|
25
26
|
|
26
27
|
# @return [Time, nil] When this workflow run started or should start.
|
27
28
|
def execution_time
|
28
|
-
@raw_info.execution_time
|
29
|
+
Internal::ProtoUtils.timestamp_to_time(@raw_info.execution_time)
|
29
30
|
end
|
30
31
|
|
31
32
|
# @return [Integer] Number of events in the history.
|
@@ -40,8 +41,7 @@ module Temporalio
|
|
40
41
|
|
41
42
|
# @return [Hash<String, Object>, nil] Memo for the workflow.
|
42
43
|
def memo
|
43
|
-
@memo
|
44
|
-
@memo
|
44
|
+
@memo.get
|
45
45
|
end
|
46
46
|
|
47
47
|
# @return [String, nil] ID for the parent workflow if this was started as a child.
|
@@ -61,15 +61,12 @@ module Temporalio
|
|
61
61
|
|
62
62
|
# @return [SearchAttributes, nil] Current set of search attributes if any.
|
63
63
|
def search_attributes
|
64
|
-
|
65
|
-
@search_attributes = SearchAttributes.from_proto(@raw_info.search_attributes)
|
66
|
-
end
|
67
|
-
@search_attributes
|
64
|
+
@search_attributes.get
|
68
65
|
end
|
69
66
|
|
70
67
|
# @return [Time] When the workflow was created.
|
71
68
|
def start_time
|
72
|
-
@raw_info.start_time
|
69
|
+
Internal::ProtoUtils.timestamp_to_time(@raw_info.start_time) || raise # Never nil
|
73
70
|
end
|
74
71
|
|
75
72
|
# @return [WorkflowExecutionStatus] Status for the workflow.
|
@@ -64,19 +64,14 @@ module Temporalio
|
|
64
64
|
#
|
65
65
|
# @param follow_runs [Boolean] If +true+, workflow runs will be continually fetched across retries and continue as
|
66
66
|
# new until the latest one is found. If +false+, the first result is used.
|
67
|
-
# @param
|
68
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
67
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
69
68
|
#
|
70
69
|
# @return [Object] Result of the workflow after being converted by the data converter.
|
71
70
|
#
|
72
71
|
# @raise [Error::WorkflowFailedError] Workflow failed with +cause+ as the cause.
|
73
72
|
# @raise [Error::WorkflowContinuedAsNewError] Workflow continued as new and +follow_runs+ is +false+.
|
74
73
|
# @raise [Error::RPCError] RPC error from call.
|
75
|
-
def result(
|
76
|
-
follow_runs: true,
|
77
|
-
rpc_metadata: nil,
|
78
|
-
rpc_timeout: nil
|
79
|
-
)
|
74
|
+
def result(follow_runs: true, rpc_options: nil)
|
80
75
|
# Wait on the close event, following as needed
|
81
76
|
hist_run_id = result_run_id
|
82
77
|
loop do
|
@@ -86,8 +81,7 @@ module Temporalio
|
|
86
81
|
event_filter_type: Api::Enums::V1::HistoryEventFilterType::HISTORY_EVENT_FILTER_TYPE_CLOSE_EVENT,
|
87
82
|
skip_archival: true,
|
88
83
|
specific_run_id: hist_run_id,
|
89
|
-
|
90
|
-
rpc_timeout:
|
84
|
+
rpc_options:
|
91
85
|
).next
|
92
86
|
|
93
87
|
# Check each close type'
|
@@ -106,13 +100,13 @@ module Temporalio
|
|
106
100
|
raise Error::WorkflowFailedError.new, cause: @client.data_converter.from_failure(attrs.failure)
|
107
101
|
when :EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED
|
108
102
|
attrs = event.workflow_execution_canceled_event_attributes
|
109
|
-
raise Error::WorkflowFailedError.new, cause: Error::CanceledError.new(
|
103
|
+
raise Error::WorkflowFailedError.new, 'Workflow execution canceled', cause: Error::CanceledError.new(
|
110
104
|
'Workflow execution canceled',
|
111
105
|
details: @client.data_converter.from_payloads(attrs&.details)
|
112
106
|
)
|
113
107
|
when :EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED
|
114
108
|
attrs = event.workflow_execution_terminated_event_attributes
|
115
|
-
raise Error::WorkflowFailedError.new, cause: Error::TerminatedError.new(
|
109
|
+
raise Error::WorkflowFailedError.new, 'Workflow execution terminated', cause: Error::TerminatedError.new(
|
116
110
|
Internal::ProtoUtils.string_or(attrs.reason, 'Workflow execution terminated'),
|
117
111
|
details: @client.data_converter.from_payloads(attrs&.details)
|
118
112
|
)
|
@@ -121,7 +115,7 @@ module Temporalio
|
|
121
115
|
hist_run_id = attrs.new_execution_run_id
|
122
116
|
next if follow_runs && hist_run_id && !hist_run_id.empty?
|
123
117
|
|
124
|
-
raise Error::WorkflowFailedError.new, cause: Error::TimeoutError.new(
|
118
|
+
raise Error::WorkflowFailedError.new, 'Workflow execution timed out', cause: Error::TimeoutError.new(
|
125
119
|
'Workflow execution timed out',
|
126
120
|
type: Api::Enums::V1::TimeoutType::TIMEOUT_TYPE_START_TO_CLOSE,
|
127
121
|
last_heartbeat_details: []
|
@@ -142,8 +136,7 @@ module Temporalio
|
|
142
136
|
# Get workflow details. This will get details for the {run_id} if present. To use a different run ID, create a new
|
143
137
|
# handle via {Client.workflow_handle}.
|
144
138
|
#
|
145
|
-
# @param
|
146
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
139
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
147
140
|
#
|
148
141
|
# @return [WorkflowExecution::Description] Workflow description.
|
149
142
|
#
|
@@ -151,15 +144,11 @@ module Temporalio
|
|
151
144
|
#
|
152
145
|
# @note Handles created as a result of {Client.start_workflow} will describe the latest workflow with the same
|
153
146
|
# workflow ID even if it is unrelated to the started workflow.
|
154
|
-
def describe(
|
155
|
-
rpc_metadata: nil,
|
156
|
-
rpc_timeout: nil
|
157
|
-
)
|
147
|
+
def describe(rpc_options: nil)
|
158
148
|
@client._impl.describe_workflow(Interceptor::DescribeWorkflowInput.new(
|
159
149
|
workflow_id: id,
|
160
150
|
run_id:,
|
161
|
-
|
162
|
-
rpc_timeout:
|
151
|
+
rpc_options:
|
163
152
|
))
|
164
153
|
end
|
165
154
|
|
@@ -167,8 +156,7 @@ module Temporalio
|
|
167
156
|
#
|
168
157
|
# @param event_filter_type [Api::Enums::V1::HistoryEventFilterType] Types of events to fetch.
|
169
158
|
# @param skip_archival [Boolean] Whether to skip archival.
|
170
|
-
# @param
|
171
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
159
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
172
160
|
#
|
173
161
|
# @return [WorkflowHistory] Workflow history.
|
174
162
|
#
|
@@ -176,15 +164,13 @@ module Temporalio
|
|
176
164
|
def fetch_history(
|
177
165
|
event_filter_type: Api::Enums::V1::HistoryEventFilterType::HISTORY_EVENT_FILTER_TYPE_ALL_EVENT,
|
178
166
|
skip_archival: false,
|
179
|
-
|
180
|
-
rpc_timeout: nil
|
167
|
+
rpc_options: nil
|
181
168
|
)
|
182
169
|
WorkflowHistory.new(
|
183
170
|
fetch_history_events(
|
184
171
|
event_filter_type:,
|
185
172
|
skip_archival:,
|
186
|
-
|
187
|
-
rpc_timeout:
|
173
|
+
rpc_options:
|
188
174
|
).to_a
|
189
175
|
)
|
190
176
|
end
|
@@ -199,8 +185,7 @@ module Temporalio
|
|
199
185
|
# @param skip_archival [Boolean] Whether to skip archival.
|
200
186
|
# @param specific_run_id [String, nil] Run ID to fetch events for. Default is the {run_id}. Most users will not
|
201
187
|
# need to set this and instead use the one on the class.
|
202
|
-
# @param
|
203
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
188
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
204
189
|
#
|
205
190
|
# @return [Enumerator<Api::History::V1::HistoryEvent>] Enumerable events.
|
206
191
|
#
|
@@ -210,8 +195,7 @@ module Temporalio
|
|
210
195
|
event_filter_type: Api::Enums::V1::HistoryEventFilterType::HISTORY_EVENT_FILTER_TYPE_ALL_EVENT,
|
211
196
|
skip_archival: false,
|
212
197
|
specific_run_id: run_id,
|
213
|
-
|
214
|
-
rpc_timeout: nil
|
198
|
+
rpc_options: nil
|
215
199
|
)
|
216
200
|
@client._impl.fetch_workflow_history_events(Interceptor::FetchWorkflowHistoryEventsInput.new(
|
217
201
|
workflow_id: id,
|
@@ -219,48 +203,39 @@ module Temporalio
|
|
219
203
|
wait_new_event:,
|
220
204
|
event_filter_type:,
|
221
205
|
skip_archival:,
|
222
|
-
|
223
|
-
rpc_timeout:
|
206
|
+
rpc_options:
|
224
207
|
))
|
225
208
|
end
|
226
209
|
|
227
210
|
# Send a signal to the workflow. This will signal for {run_id} if present. To use a different run ID, create a new
|
228
211
|
# handle via {Client.workflow_handle}.
|
229
212
|
#
|
230
|
-
# @param signal [String] Signal name.
|
213
|
+
# @param signal [Workflow::Definition::Signal, Symbol, String] Signal definition or name.
|
231
214
|
# @param args [Array<Object>] Signal arguments.
|
232
|
-
# @param
|
233
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
215
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
234
216
|
#
|
235
217
|
# @raise [Error::RPCError] RPC error from call.
|
236
218
|
#
|
237
219
|
# @note Handles created as a result of {Client.start_workflow} will signal the latest workflow with the same
|
238
220
|
# workflow ID even if it is unrelated to the started workflow.
|
239
|
-
def signal(
|
240
|
-
signal,
|
241
|
-
*args,
|
242
|
-
rpc_metadata: nil,
|
243
|
-
rpc_timeout: nil
|
244
|
-
)
|
221
|
+
def signal(signal, *args, rpc_options: nil)
|
245
222
|
@client._impl.signal_workflow(Interceptor::SignalWorkflowInput.new(
|
246
223
|
workflow_id: id,
|
247
224
|
run_id:,
|
248
225
|
signal:,
|
249
226
|
args:,
|
250
227
|
headers: {},
|
251
|
-
|
252
|
-
rpc_timeout:
|
228
|
+
rpc_options:
|
253
229
|
))
|
254
230
|
end
|
255
231
|
|
256
232
|
# Query the workflow. This will query for {run_id} if present. To use a different run ID, create a new handle via
|
257
233
|
# {Client.workflow_handle}.
|
258
234
|
#
|
259
|
-
# @param query [String] Query name.
|
235
|
+
# @param query [Workflow::Definition::Query, Symbol, String] Query definition or name.
|
260
236
|
# @param args [Array<Object>] Query arguments.
|
261
237
|
# @param reject_condition [WorkflowQueryRejectCondition, nil] Condition for rejecting the query.
|
262
|
-
# @param
|
263
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
238
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
264
239
|
#
|
265
240
|
# @return [Object, nil] Query result.
|
266
241
|
#
|
@@ -274,8 +249,7 @@ module Temporalio
|
|
274
249
|
query,
|
275
250
|
*args,
|
276
251
|
reject_condition: @client.options.default_workflow_query_reject_condition,
|
277
|
-
|
278
|
-
rpc_timeout: nil
|
252
|
+
rpc_options: nil
|
279
253
|
)
|
280
254
|
@client._impl.query_workflow(Interceptor::QueryWorkflowInput.new(
|
281
255
|
workflow_id: id,
|
@@ -284,21 +258,19 @@ module Temporalio
|
|
284
258
|
args:,
|
285
259
|
reject_condition:,
|
286
260
|
headers: {},
|
287
|
-
|
288
|
-
rpc_timeout:
|
261
|
+
rpc_options:
|
289
262
|
))
|
290
263
|
end
|
291
264
|
|
292
265
|
# Send an update request to the workflow and return a handle to it. This will target the workflow with {run_id} if
|
293
266
|
# present. To use a different run ID, create a new handle via {Client.workflow_handle}.
|
294
267
|
#
|
295
|
-
# @param update [String] Update name.
|
268
|
+
# @param update [Workflow::Definition::Update, Symbol, String] Update definition or name.
|
296
269
|
# @param args [Array<Object>] Update arguments.
|
297
270
|
# @param wait_for_stage [WorkflowUpdateWaitStage] Required stage to wait until returning. ADMITTED is not
|
298
271
|
# currently supported. See https://docs.temporal.io/workflows#update for more details.
|
299
272
|
# @param id [String] ID of the update.
|
300
|
-
# @param
|
301
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
273
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
302
274
|
#
|
303
275
|
# @return [WorkflowUpdateHandle] The update handle.
|
304
276
|
#
|
@@ -308,14 +280,12 @@ module Temporalio
|
|
308
280
|
#
|
309
281
|
# @note Handles created as a result of {Client.start_workflow} will send updates the latest workflow with the same
|
310
282
|
# workflow ID even if it is unrelated to the started workflow.
|
311
|
-
# @note WARNING: This API is experimental.
|
312
283
|
def start_update(
|
313
284
|
update,
|
314
285
|
*args,
|
315
286
|
wait_for_stage:,
|
316
287
|
id: SecureRandom.uuid,
|
317
|
-
|
318
|
-
rpc_timeout: nil
|
288
|
+
rpc_options: nil
|
319
289
|
)
|
320
290
|
@client._impl.start_workflow_update(Interceptor::StartWorkflowUpdateInput.new(
|
321
291
|
workflow_id: self.id,
|
@@ -325,19 +295,17 @@ module Temporalio
|
|
325
295
|
args:,
|
326
296
|
wait_for_stage:,
|
327
297
|
headers: {},
|
328
|
-
|
329
|
-
rpc_timeout:
|
298
|
+
rpc_options:
|
330
299
|
))
|
331
300
|
end
|
332
301
|
|
333
302
|
# Send an update request to the workflow and wait for it to complete. This will target the workflow with {run_id}
|
334
303
|
# if present. To use a different run ID, create a new handle via {Client.workflow_handle}.
|
335
304
|
#
|
336
|
-
# @param update [String] Update name.
|
305
|
+
# @param update [Workflow::Definition::Update, Symbol, String] Update definition or name.
|
337
306
|
# @param args [Array<Object>] Update arguments.
|
338
307
|
# @param id [String] ID of the update.
|
339
|
-
# @param
|
340
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
308
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
341
309
|
#
|
342
310
|
# @return [Object, nil] Update result.
|
343
311
|
#
|
@@ -348,21 +316,13 @@ module Temporalio
|
|
348
316
|
#
|
349
317
|
# @note Handles created as a result of {Client.start_workflow} will send updates the latest workflow with the same
|
350
318
|
# workflow ID even if it is unrelated to the started workflow.
|
351
|
-
|
352
|
-
def execute_update(
|
353
|
-
update,
|
354
|
-
*args,
|
355
|
-
id: SecureRandom.uuid,
|
356
|
-
rpc_metadata: nil,
|
357
|
-
rpc_timeout: nil
|
358
|
-
)
|
319
|
+
def execute_update(update, *args, id: SecureRandom.uuid, rpc_options: nil)
|
359
320
|
start_update(
|
360
321
|
update,
|
361
322
|
*args,
|
362
323
|
wait_for_stage: WorkflowUpdateWaitStage::COMPLETED,
|
363
324
|
id:,
|
364
|
-
|
365
|
-
rpc_timeout:
|
325
|
+
rpc_options:
|
366
326
|
).result
|
367
327
|
end
|
368
328
|
|
@@ -373,12 +333,7 @@ module Temporalio
|
|
373
333
|
# users will not need to set this and instead use the one on the class.
|
374
334
|
#
|
375
335
|
# @return [WorkflowUpdateHandle] The update handle.
|
376
|
-
|
377
|
-
# @note WARNING: This API is experimental.
|
378
|
-
def update_handle(
|
379
|
-
id,
|
380
|
-
specific_run_id: run_id
|
381
|
-
)
|
336
|
+
def update_handle(id, specific_run_id: run_id)
|
382
337
|
WorkflowUpdateHandle.new(
|
383
338
|
client: @client,
|
384
339
|
id:,
|
@@ -392,23 +347,18 @@ module Temporalio
|
|
392
347
|
# run chain starting from {first_execution_run_id} if present. To create handles with these values, use
|
393
348
|
# {Client.workflow_handle}.
|
394
349
|
#
|
395
|
-
# @param
|
396
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
350
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
397
351
|
#
|
398
352
|
# @raise [Error::RPCError] RPC error from call.
|
399
353
|
#
|
400
354
|
# @note Handles created as a result of signal with start will cancel the latest workflow with the same workflow ID
|
401
355
|
# even if it is unrelated to the started workflow.
|
402
|
-
def cancel(
|
403
|
-
rpc_metadata: nil,
|
404
|
-
rpc_timeout: nil
|
405
|
-
)
|
356
|
+
def cancel(rpc_options: nil)
|
406
357
|
@client._impl.cancel_workflow(Interceptor::CancelWorkflowInput.new(
|
407
358
|
workflow_id: id,
|
408
359
|
run_id:,
|
409
360
|
first_execution_run_id:,
|
410
|
-
|
411
|
-
rpc_timeout:
|
361
|
+
rpc_options:
|
412
362
|
))
|
413
363
|
end
|
414
364
|
|
@@ -418,27 +368,20 @@ module Temporalio
|
|
418
368
|
#
|
419
369
|
# @param reason [String, nil] Reason for the termination.
|
420
370
|
# @param details [Array<Object>] Details to store on the termination.
|
421
|
-
# @param
|
422
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
371
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
423
372
|
#
|
424
373
|
# @raise [Error::RPCError] RPC error from call.
|
425
374
|
#
|
426
375
|
# @note Handles created as a result of signal with start will terminate the latest workflow with the same workflow
|
427
376
|
# ID even if it is unrelated to the started workflow.
|
428
|
-
def terminate(
|
429
|
-
reason = nil,
|
430
|
-
details: [],
|
431
|
-
rpc_metadata: nil,
|
432
|
-
rpc_timeout: nil
|
433
|
-
)
|
377
|
+
def terminate(reason = nil, details: [], rpc_options: nil)
|
434
378
|
@client._impl.terminate_workflow(Interceptor::TerminateWorkflowInput.new(
|
435
379
|
workflow_id: id,
|
436
380
|
run_id:,
|
437
381
|
first_execution_run_id:,
|
438
382
|
reason:,
|
439
383
|
details:,
|
440
|
-
|
441
|
-
rpc_timeout:
|
384
|
+
rpc_options:
|
442
385
|
))
|
443
386
|
end
|
444
387
|
end
|
@@ -36,8 +36,7 @@ module Temporalio
|
|
36
36
|
# Wait for and return the result of the update. The result may already be known in which case no network call is
|
37
37
|
# made. Otherwise the result will be polled for until it is returned.
|
38
38
|
#
|
39
|
-
# @param
|
40
|
-
# @param rpc_timeout [Float, nil] Number of seconds before timeout.
|
39
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
41
40
|
#
|
42
41
|
# @return [Object, nil] Update result.
|
43
42
|
#
|
@@ -45,13 +44,12 @@ module Temporalio
|
|
45
44
|
# @raise [Error::WorkflowUpdateRPCTimeoutOrCanceledError] This update call timed out or was canceled. This doesn't
|
46
45
|
# mean the update itself was timed out or canceled.
|
47
46
|
# @raise [Error::RPCError] RPC error from call.
|
48
|
-
def result(
|
47
|
+
def result(rpc_options: nil)
|
49
48
|
@known_outcome ||= @client._impl.poll_workflow_update(Interceptor::PollWorkflowUpdateInput.new(
|
50
49
|
workflow_id:,
|
51
50
|
run_id: workflow_run_id,
|
52
51
|
update_id: id,
|
53
|
-
|
54
|
-
rpc_timeout:
|
52
|
+
rpc_options:
|
55
53
|
))
|
56
54
|
|
57
55
|
if @known_outcome.failure
|