temporalio 0.4.0-aarch64-linux-musl

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 (183) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +2 -0
  3. data/Gemfile +27 -0
  4. data/Rakefile +101 -0
  5. data/lib/temporalio/activity/complete_async_error.rb +11 -0
  6. data/lib/temporalio/activity/context.rb +123 -0
  7. data/lib/temporalio/activity/definition.rb +192 -0
  8. data/lib/temporalio/activity/info.rb +67 -0
  9. data/lib/temporalio/activity.rb +12 -0
  10. data/lib/temporalio/api/activity/v1/message.rb +25 -0
  11. data/lib/temporalio/api/batch/v1/message.rb +36 -0
  12. data/lib/temporalio/api/cloud/account/v1/message.rb +28 -0
  13. data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +126 -0
  14. data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +25 -0
  15. data/lib/temporalio/api/cloud/cloudservice.rb +3 -0
  16. data/lib/temporalio/api/cloud/identity/v1/message.rb +41 -0
  17. data/lib/temporalio/api/cloud/namespace/v1/message.rb +42 -0
  18. data/lib/temporalio/api/cloud/nexus/v1/message.rb +31 -0
  19. data/lib/temporalio/api/cloud/operation/v1/message.rb +28 -0
  20. data/lib/temporalio/api/cloud/region/v1/message.rb +24 -0
  21. data/lib/temporalio/api/cloud/resource/v1/message.rb +23 -0
  22. data/lib/temporalio/api/cloud/sink/v1/message.rb +24 -0
  23. data/lib/temporalio/api/cloud/usage/v1/message.rb +31 -0
  24. data/lib/temporalio/api/command/v1/message.rb +46 -0
  25. data/lib/temporalio/api/common/v1/grpc_status.rb +23 -0
  26. data/lib/temporalio/api/common/v1/message.rb +48 -0
  27. data/lib/temporalio/api/deployment/v1/message.rb +38 -0
  28. data/lib/temporalio/api/enums/v1/batch_operation.rb +22 -0
  29. data/lib/temporalio/api/enums/v1/command_type.rb +21 -0
  30. data/lib/temporalio/api/enums/v1/common.rb +26 -0
  31. data/lib/temporalio/api/enums/v1/deployment.rb +23 -0
  32. data/lib/temporalio/api/enums/v1/event_type.rb +21 -0
  33. data/lib/temporalio/api/enums/v1/failed_cause.rb +26 -0
  34. data/lib/temporalio/api/enums/v1/namespace.rb +23 -0
  35. data/lib/temporalio/api/enums/v1/nexus.rb +21 -0
  36. data/lib/temporalio/api/enums/v1/query.rb +22 -0
  37. data/lib/temporalio/api/enums/v1/reset.rb +23 -0
  38. data/lib/temporalio/api/enums/v1/schedule.rb +21 -0
  39. data/lib/temporalio/api/enums/v1/task_queue.rb +25 -0
  40. data/lib/temporalio/api/enums/v1/update.rb +22 -0
  41. data/lib/temporalio/api/enums/v1/workflow.rb +31 -0
  42. data/lib/temporalio/api/errordetails/v1/message.rb +44 -0
  43. data/lib/temporalio/api/export/v1/message.rb +24 -0
  44. data/lib/temporalio/api/failure/v1/message.rb +37 -0
  45. data/lib/temporalio/api/filter/v1/message.rb +27 -0
  46. data/lib/temporalio/api/history/v1/message.rb +92 -0
  47. data/lib/temporalio/api/namespace/v1/message.rb +31 -0
  48. data/lib/temporalio/api/nexus/v1/message.rb +41 -0
  49. data/lib/temporalio/api/operatorservice/v1/request_response.rb +49 -0
  50. data/lib/temporalio/api/operatorservice/v1/service.rb +23 -0
  51. data/lib/temporalio/api/operatorservice.rb +3 -0
  52. data/lib/temporalio/api/payload_visitor.rb +1581 -0
  53. data/lib/temporalio/api/protocol/v1/message.rb +23 -0
  54. data/lib/temporalio/api/query/v1/message.rb +28 -0
  55. data/lib/temporalio/api/replication/v1/message.rb +26 -0
  56. data/lib/temporalio/api/schedule/v1/message.rb +43 -0
  57. data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +25 -0
  58. data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +21 -0
  59. data/lib/temporalio/api/sdk/v1/user_metadata.rb +23 -0
  60. data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +23 -0
  61. data/lib/temporalio/api/taskqueue/v1/message.rb +48 -0
  62. data/lib/temporalio/api/testservice/v1/request_response.rb +31 -0
  63. data/lib/temporalio/api/testservice/v1/service.rb +23 -0
  64. data/lib/temporalio/api/update/v1/message.rb +33 -0
  65. data/lib/temporalio/api/version/v1/message.rb +26 -0
  66. data/lib/temporalio/api/workflow/v1/message.rb +51 -0
  67. data/lib/temporalio/api/workflowservice/v1/request_response.rb +233 -0
  68. data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
  69. data/lib/temporalio/api/workflowservice.rb +3 -0
  70. data/lib/temporalio/api.rb +15 -0
  71. data/lib/temporalio/cancellation.rb +170 -0
  72. data/lib/temporalio/client/activity_id_reference.rb +32 -0
  73. data/lib/temporalio/client/async_activity_handle.rb +85 -0
  74. data/lib/temporalio/client/connection/cloud_service.rb +726 -0
  75. data/lib/temporalio/client/connection/operator_service.rb +201 -0
  76. data/lib/temporalio/client/connection/service.rb +42 -0
  77. data/lib/temporalio/client/connection/test_service.rb +111 -0
  78. data/lib/temporalio/client/connection/workflow_service.rb +1251 -0
  79. data/lib/temporalio/client/connection.rb +316 -0
  80. data/lib/temporalio/client/interceptor.rb +455 -0
  81. data/lib/temporalio/client/schedule.rb +991 -0
  82. data/lib/temporalio/client/schedule_handle.rb +126 -0
  83. data/lib/temporalio/client/with_start_workflow_operation.rb +115 -0
  84. data/lib/temporalio/client/workflow_execution.rb +119 -0
  85. data/lib/temporalio/client/workflow_execution_count.rb +36 -0
  86. data/lib/temporalio/client/workflow_execution_status.rb +18 -0
  87. data/lib/temporalio/client/workflow_handle.rb +389 -0
  88. data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
  89. data/lib/temporalio/client/workflow_update_handle.rb +65 -0
  90. data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
  91. data/lib/temporalio/client.rb +607 -0
  92. data/lib/temporalio/common_enums.rb +41 -0
  93. data/lib/temporalio/contrib/open_telemetry.rb +470 -0
  94. data/lib/temporalio/converters/data_converter.rb +99 -0
  95. data/lib/temporalio/converters/failure_converter.rb +202 -0
  96. data/lib/temporalio/converters/payload_codec.rb +26 -0
  97. data/lib/temporalio/converters/payload_converter/binary_null.rb +34 -0
  98. data/lib/temporalio/converters/payload_converter/binary_plain.rb +35 -0
  99. data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +42 -0
  100. data/lib/temporalio/converters/payload_converter/composite.rb +66 -0
  101. data/lib/temporalio/converters/payload_converter/encoding.rb +35 -0
  102. data/lib/temporalio/converters/payload_converter/json_plain.rb +44 -0
  103. data/lib/temporalio/converters/payload_converter/json_protobuf.rb +41 -0
  104. data/lib/temporalio/converters/payload_converter.rb +71 -0
  105. data/lib/temporalio/converters/raw_value.rb +20 -0
  106. data/lib/temporalio/converters.rb +9 -0
  107. data/lib/temporalio/error/failure.rb +219 -0
  108. data/lib/temporalio/error.rb +156 -0
  109. data/lib/temporalio/internal/bridge/3.2/temporalio_bridge.so +0 -0
  110. data/lib/temporalio/internal/bridge/3.3/temporalio_bridge.so +0 -0
  111. data/lib/temporalio/internal/bridge/3.4/temporalio_bridge.so +0 -0
  112. data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +34 -0
  113. data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +31 -0
  114. data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +33 -0
  115. data/lib/temporalio/internal/bridge/api/common/common.rb +27 -0
  116. data/lib/temporalio/internal/bridge/api/core_interface.rb +40 -0
  117. data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
  118. data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +33 -0
  119. data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +56 -0
  120. data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +57 -0
  121. data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +31 -0
  122. data/lib/temporalio/internal/bridge/api.rb +3 -0
  123. data/lib/temporalio/internal/bridge/client.rb +95 -0
  124. data/lib/temporalio/internal/bridge/runtime.rb +56 -0
  125. data/lib/temporalio/internal/bridge/testing.rb +69 -0
  126. data/lib/temporalio/internal/bridge/worker.rb +85 -0
  127. data/lib/temporalio/internal/bridge.rb +36 -0
  128. data/lib/temporalio/internal/client/implementation.rb +922 -0
  129. data/lib/temporalio/internal/metric.rb +122 -0
  130. data/lib/temporalio/internal/proto_utils.rb +165 -0
  131. data/lib/temporalio/internal/worker/activity_worker.rb +385 -0
  132. data/lib/temporalio/internal/worker/multi_runner.rb +213 -0
  133. data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +54 -0
  134. data/lib/temporalio/internal/worker/workflow_instance/context.rb +383 -0
  135. data/lib/temporalio/internal/worker/workflow_instance/details.rb +46 -0
  136. data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +32 -0
  137. data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +22 -0
  138. data/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb +25 -0
  139. data/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb +41 -0
  140. data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +97 -0
  141. data/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb +62 -0
  142. data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +400 -0
  143. data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +37 -0
  144. data/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb +40 -0
  145. data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +183 -0
  146. data/lib/temporalio/internal/worker/workflow_instance.rb +774 -0
  147. data/lib/temporalio/internal/worker/workflow_worker.rb +239 -0
  148. data/lib/temporalio/internal.rb +7 -0
  149. data/lib/temporalio/metric.rb +109 -0
  150. data/lib/temporalio/retry_policy.rb +74 -0
  151. data/lib/temporalio/runtime/metric_buffer.rb +94 -0
  152. data/lib/temporalio/runtime.rb +352 -0
  153. data/lib/temporalio/scoped_logger.rb +96 -0
  154. data/lib/temporalio/search_attributes.rb +356 -0
  155. data/lib/temporalio/testing/activity_environment.rb +160 -0
  156. data/lib/temporalio/testing/workflow_environment.rb +406 -0
  157. data/lib/temporalio/testing.rb +10 -0
  158. data/lib/temporalio/version.rb +5 -0
  159. data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
  160. data/lib/temporalio/worker/activity_executor/thread_pool.rb +46 -0
  161. data/lib/temporalio/worker/activity_executor.rb +55 -0
  162. data/lib/temporalio/worker/interceptor.rb +365 -0
  163. data/lib/temporalio/worker/thread_pool.rb +237 -0
  164. data/lib/temporalio/worker/tuner.rb +189 -0
  165. data/lib/temporalio/worker/workflow_executor/thread_pool.rb +235 -0
  166. data/lib/temporalio/worker/workflow_executor.rb +26 -0
  167. data/lib/temporalio/worker/workflow_replayer.rb +350 -0
  168. data/lib/temporalio/worker.rb +603 -0
  169. data/lib/temporalio/workflow/activity_cancellation_type.rb +20 -0
  170. data/lib/temporalio/workflow/child_workflow_cancellation_type.rb +21 -0
  171. data/lib/temporalio/workflow/child_workflow_handle.rb +43 -0
  172. data/lib/temporalio/workflow/definition.rb +598 -0
  173. data/lib/temporalio/workflow/external_workflow_handle.rb +41 -0
  174. data/lib/temporalio/workflow/future.rb +151 -0
  175. data/lib/temporalio/workflow/handler_unfinished_policy.rb +13 -0
  176. data/lib/temporalio/workflow/info.rb +104 -0
  177. data/lib/temporalio/workflow/parent_close_policy.rb +19 -0
  178. data/lib/temporalio/workflow/update_info.rb +20 -0
  179. data/lib/temporalio/workflow.rb +575 -0
  180. data/lib/temporalio/workflow_history.rb +47 -0
  181. data/lib/temporalio.rb +11 -0
  182. data/temporalio.gemspec +29 -0
  183. metadata +258 -0
@@ -0,0 +1,991 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'temporalio/api'
4
+ require 'temporalio/converters'
5
+ require 'temporalio/internal/proto_utils'
6
+ require 'temporalio/retry_policy'
7
+ require 'temporalio/search_attributes'
8
+
9
+ module Temporalio
10
+ class Client
11
+ Schedule = Data.define(
12
+ :action,
13
+ :spec,
14
+ :policy,
15
+ :state
16
+ )
17
+
18
+ # A schedule for periodically running an action.
19
+ #
20
+ # @!attribute action
21
+ # @return [Action] Action taken when scheduled.
22
+ # @!attribute spec
23
+ # @return [Spec] When the action is taken.
24
+ # @!attribute policy
25
+ # @return [Policy] Schedule policies.
26
+ # @!attribute state
27
+ # @return [State] State of the schedule.
28
+ class Schedule
29
+ # @!visibility private
30
+ def self._from_proto(raw_schedule, data_converter)
31
+ Schedule.new(
32
+ action: Action._from_proto(raw_schedule.action, data_converter),
33
+ spec: Spec._from_proto(raw_schedule.spec),
34
+ policy: Policy._from_proto(raw_schedule.policies),
35
+ state: State._from_proto(raw_schedule.state)
36
+ )
37
+ end
38
+
39
+ # Create schedule
40
+ #
41
+ # @param action [Action] Action taken when scheduled.
42
+ # @param spec [Spec] When the action is taken.
43
+ # @param policy [Policy] Schedule policies.
44
+ # @param state [State] State of the schedule.
45
+ def initialize(action:, spec:, policy: Policy.new, state: State.new)
46
+ super
47
+ end
48
+
49
+ # @!visibility private
50
+ def _to_proto(data_converter)
51
+ Api::Schedule::V1::Schedule.new(
52
+ spec: spec._to_proto,
53
+ action: action._to_proto(data_converter),
54
+ policies: policy._to_proto,
55
+ state: state._to_proto
56
+ )
57
+ end
58
+
59
+ Description = Data.define( # rubocop:disable Layout/ClassStructure
60
+ :id,
61
+ :schedule,
62
+ :info,
63
+ :raw_description
64
+ )
65
+
66
+ # Description of a schedule.
67
+ #
68
+ # @!attribute id
69
+ # @return [String] ID of the schedule.
70
+ # @!attribute schedule
71
+ # @return [Schedule] Schedule details.
72
+ # @!attribute info
73
+ # @return [Schedule::Info] Information about the schedule.
74
+ # @!attribute raw_description
75
+ # @return [Api::WorkflowService::V1::DescribeScheduleResponse] Raw description of the schedule.
76
+ class Description
77
+ # @!visibility private
78
+ def initialize(id:, raw_description:, data_converter:)
79
+ @memo = Internal::ProtoUtils::LazyMemo.new(raw_description.memo, data_converter)
80
+ @search_attributes = Internal::ProtoUtils::LazySearchAttributes.new(raw_description.search_attributes)
81
+ # steep:ignore:start
82
+ super(
83
+ id:,
84
+ schedule: Schedule._from_proto(raw_description.schedule, data_converter),
85
+ info: Info.new(raw_info: raw_description.info),
86
+ raw_description:
87
+ )
88
+ # steep:ignore:end
89
+ end
90
+
91
+ # @return [Hash<String, Object>, nil] Memo for the schedule, converted lazily on first call.
92
+ def memo
93
+ @memo.get
94
+ end
95
+
96
+ # @return [SearchAttributes, nil] Search attributes for the schedule, converted lazily on first call.
97
+ def search_attributes
98
+ @search_attributes.get
99
+ end
100
+ end
101
+
102
+ Info = Data.define(
103
+ :num_actions,
104
+ :num_actions_missed_catchup_window,
105
+ :num_actions_skipped_overlap,
106
+ :running_actions,
107
+ :recent_actions,
108
+ :next_action_times,
109
+ :created_at,
110
+ :last_updated_at
111
+ )
112
+
113
+ # Information about a schedule.
114
+ #
115
+ # @!attribute num_actions
116
+ # @return [Integer] Number of actions taken by this schedule.
117
+ # @!attribute num_actions_missed_catchup_window
118
+ # @return [Integer] Number of times an action was skipped due to missing the catchup window.
119
+ # @!attribute num_actions_skipped_overlap
120
+ # @return [Integer] Number of actions skipped due to overlap.
121
+ # @!attribute running_actions
122
+ # @return [Array<ActionExecution>] Currently running actions.
123
+ # @!attribute recent_actions
124
+ # @return [Array<ActionResult>] 10 most recent actions, oldest first.
125
+ # @!attribute next_action_times
126
+ # @return [Array<Time>] Next 10 scheduled action times.
127
+ # @!attribute created_at
128
+ # @return [Time] When the schedule was created.
129
+ # @!attribute last_updated_at
130
+ # @return [Time, nil] When the schedule was last updated.
131
+ class Info
132
+ # @!visibility private
133
+ def initialize(raw_info:)
134
+ # steep:ignore:start
135
+ super(
136
+ num_actions: raw_info.action_count,
137
+ num_actions_missed_catchup_window: raw_info.missed_catchup_window,
138
+ num_actions_skipped_overlap: raw_info.overlap_skipped,
139
+ running_actions: raw_info.running_workflows.map do |w|
140
+ ActionExecution::StartWorkflow.new(raw_execution: w)
141
+ end,
142
+ recent_actions: raw_info.recent_actions.map { |a| ActionResult.new(raw_result: a) },
143
+ next_action_times: raw_info.future_action_times.map { |t| Internal::ProtoUtils.timestamp_to_time(t) },
144
+ created_at: Internal::ProtoUtils.timestamp_to_time(raw_info.create_time),
145
+ last_updated_at: Internal::ProtoUtils.timestamp_to_time(raw_info.update_time)
146
+ )
147
+ # steep:ignore:end
148
+ end
149
+ end
150
+
151
+ # Base module mixed in by specific actions a schedule can take.
152
+ module Action
153
+ # @!visibility private
154
+ def self._from_proto(raw_action, data_converter)
155
+ raise "Unsupported action: #{raw_action.action}" unless raw_action.start_workflow
156
+
157
+ StartWorkflow._from_proto(raw_action.start_workflow, data_converter)
158
+ end
159
+
160
+ # @!visibility private
161
+ def _to_proto(data_converter)
162
+ raise NotImplementedError
163
+ end
164
+
165
+ StartWorkflow = Data.define(
166
+ :workflow,
167
+ :args,
168
+ :id,
169
+ :task_queue,
170
+ :static_summary,
171
+ :static_details,
172
+ :execution_timeout,
173
+ :run_timeout,
174
+ :task_timeout,
175
+ :retry_policy,
176
+ :memo,
177
+ :search_attributes,
178
+ :headers
179
+ )
180
+
181
+ # Schedule action to start a workflow.
182
+ #
183
+ # @!attribute workflow
184
+ # @return [String] Workflow.
185
+ # @!attribute args
186
+ # @return [Array<Object>] Arguments to the workflow.
187
+ # @!attribute id
188
+ # @return [String] Unique identifier for the workflow execution.
189
+ # @!attribute task_queue
190
+ # @return [String] Task queue to run the workflow on.
191
+ # @!attribute static_summary
192
+ # @return [String, nil] Fixed single-line summary for this workflow execution that may appear in CLI/UI.
193
+ # This can be in single-line Temporal markdown format. This is currently experimental.
194
+ # @!attribute static_details
195
+ # @return [String, nil] Fixed details for this workflow execution that may appear in CLI/UI. This can be in
196
+ # Temporal markdown format and can be multiple lines. This is a fixed value on the workflow that cannot be
197
+ # updated. For details that can be updated, use {Workflow.current_details=} within the workflow. This is
198
+ # currently experimental.
199
+ # @!attribute execution_timeout
200
+ # @return [Float, nil] Total workflow execution timeout in seconds including retries and continue as new.
201
+ # @!attribute run_timeout
202
+ # @return [Float, nil] Timeout of a single workflow run in seconds.
203
+ # @!attribute task_timeout
204
+ # @return [Float, nil] Timeout of a single workflow task in seconds.
205
+ # @!attribute retry_policy
206
+ # @return [RetryPolicy, nil] Retry policy for the workflow.
207
+ # @!attribute memo
208
+ # @return [Hash<String, Object>, nil] Memo for the workflow.
209
+ # @!attribute search_attributes
210
+ # @return [SearchAttributes, nil] Search attributes for the workflow.
211
+ # @!attribute headers
212
+ # @return [Hash<String, Object>, nil] Headers for the workflow.
213
+ class StartWorkflow
214
+ include Action
215
+
216
+ class << self
217
+ alias _original_new new
218
+
219
+ # Create start-workflow schedule action.
220
+ #
221
+ # @param workflow [Class<Workflow::Definition>, Symbol, String] Workflow.
222
+ # @param args [Array<Object>] Arguments to the workflow.
223
+ # @param id [String] Unique identifier for the workflow execution.
224
+ # @param task_queue [String] Task queue to run the workflow on.
225
+ # @param static_summary [String, nil] Fixed single-line summary for this workflow execution that may appear
226
+ # in CLI/UI. This can be in single-line Temporal markdown format. This is currently experimental.
227
+ # @param static_details [String, nil] Fixed details for this workflow execution that may appear in CLI/UI.
228
+ # This can be in Temporal markdown format and can be multiple lines. This is a fixed value on the workflow
229
+ # that cannot be updated. For details that can be updated, use {Workflow.current_details=} within the
230
+ # workflow. This is currently experimental.
231
+ # @param execution_timeout [Float, nil] Total workflow execution timeout in seconds including retries and
232
+ # continue as new.
233
+ # @param run_timeout [Float, nil] Timeout of a single workflow run in seconds.
234
+ # @param task_timeout [Float, nil] Timeout of a single workflow task in seconds.
235
+ # @param retry_policy [RetryPolicy, nil] Retry policy for the workflow.
236
+ # @param memo [Hash<String, Object>, nil] Memo for the workflow.
237
+ # @param search_attributes [SearchAttributes, nil] Search attributes for the workflow.
238
+ # @param headers [Hash<String, Object>, nil] Headers for the workflow.
239
+ def new(
240
+ workflow,
241
+ *args,
242
+ id:,
243
+ task_queue:,
244
+ static_summary: nil,
245
+ static_details: nil,
246
+ execution_timeout: nil,
247
+ run_timeout: nil,
248
+ task_timeout: nil,
249
+ retry_policy: nil,
250
+ memo: nil,
251
+ search_attributes: nil,
252
+ headers: nil
253
+ )
254
+ _original_new( # steep:ignore
255
+ workflow: Workflow::Definition._workflow_type_from_workflow_parameter(workflow),
256
+ args:,
257
+ id:,
258
+ task_queue:,
259
+ static_summary:,
260
+ static_details:,
261
+ execution_timeout:,
262
+ run_timeout:,
263
+ task_timeout:,
264
+ retry_policy:,
265
+ memo:,
266
+ search_attributes:,
267
+ headers:
268
+ )
269
+ end
270
+ end
271
+
272
+ # @!visibility private
273
+ def self._from_proto(raw_info, data_converter)
274
+ (summary, details) = Internal::ProtoUtils.from_user_metadata(raw_info.user_metadata, data_converter)
275
+ StartWorkflow.new(
276
+ raw_info.workflow_type.name,
277
+ *data_converter.from_payloads(raw_info.input),
278
+ id: raw_info.workflow_id,
279
+ task_queue: raw_info.task_queue.name,
280
+ static_summary: summary,
281
+ static_details: details,
282
+ execution_timeout: Internal::ProtoUtils.duration_to_seconds(raw_info.workflow_execution_timeout),
283
+ run_timeout: Internal::ProtoUtils.duration_to_seconds(raw_info.workflow_run_timeout),
284
+ task_timeout: Internal::ProtoUtils.duration_to_seconds(raw_info.workflow_task_timeout),
285
+ retry_policy: raw_info.retry_policy ? RetryPolicy._from_proto(raw_info.retry_policy) : nil,
286
+ memo: Internal::ProtoUtils.memo_from_proto(raw_info.memo, data_converter),
287
+ search_attributes: SearchAttributes._from_proto(raw_info.search_attributes),
288
+ headers: Internal::ProtoUtils.headers_from_proto(raw_info.header, data_converter)
289
+ )
290
+ end
291
+
292
+ # @!visibility private
293
+ def _to_proto(data_converter)
294
+ Api::Schedule::V1::ScheduleAction.new(
295
+ start_workflow: Api::Workflow::V1::NewWorkflowExecutionInfo.new(
296
+ workflow_id: id,
297
+ workflow_type: Api::Common::V1::WorkflowType.new(name: workflow),
298
+ task_queue: Api::TaskQueue::V1::TaskQueue.new(name: task_queue),
299
+ input: data_converter.to_payloads(args),
300
+ workflow_execution_timeout: Internal::ProtoUtils.seconds_to_duration(execution_timeout),
301
+ workflow_run_timeout: Internal::ProtoUtils.seconds_to_duration(run_timeout),
302
+ workflow_task_timeout: Internal::ProtoUtils.seconds_to_duration(task_timeout),
303
+ retry_policy: retry_policy&._to_proto,
304
+ memo: Internal::ProtoUtils.memo_to_proto(memo, data_converter),
305
+ search_attributes: search_attributes&._to_proto,
306
+ header: Internal::ProtoUtils.headers_to_proto(headers, data_converter),
307
+ user_metadata: Internal::ProtoUtils.to_user_metadata(static_summary, static_details, data_converter)
308
+ )
309
+ )
310
+ end
311
+ end
312
+ end
313
+
314
+ # Enumerate that controls what happens when a workflow would be started by a schedule but one is already running.
315
+ module OverlapPolicy
316
+ # Don't start anything. When the workflow completes, the next scheduled event after that time will be
317
+ # considered.
318
+ SKIP = Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_SKIP
319
+
320
+ # Start the workflow again soon as the current one completes, but only buffer one start in this way. If another
321
+ # start is supposed to happen when the workflow is running, and one is already buffered, then only the first one
322
+ # will be started after the running workflow finishes.
323
+ BUFFER_ONE = Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_BUFFER_ONE
324
+
325
+ # Buffer up any number of starts to all happen sequentially, immediately after the running workflow completes.
326
+ BUFFER_ALL = Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_BUFFER_ALL
327
+
328
+ # If there is another workflow running, cancel it, and start the new one after the old one completes
329
+ # cancellation.
330
+ CANCEL_OTHER = Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_CANCEL_OTHER
331
+
332
+ # If there is another workflow running, terminate it and start the new one immediately.
333
+ TERMINATE_OTHER = Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_TERMINATE_OTHER
334
+
335
+ # Start any number of concurrent workflows. Note that with this policy, last completion result and last failure
336
+ # will not be available since workflows are not sequential.
337
+ ALLOW_ALL = Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_ALLOW_ALL
338
+ end
339
+
340
+ Backfill = Data.define(
341
+ :start_at,
342
+ :end_at,
343
+ :overlap
344
+ )
345
+
346
+ # Time period and policy for actions taken as if the time passed right now.
347
+ #
348
+ # @!attribute start_at
349
+ # @return [Time] Start of the range to evaluate the schedule in. This is exclusive.
350
+ # @!attribute end_at
351
+ # @return [Time] End of the range to evaluate the schedule in. This is inclusive.
352
+ # @!attribute overlap
353
+ # @return [OverlapPolicy] Overlap policy.
354
+ class Backfill
355
+ # Create backfill.
356
+ #
357
+ # @param start_at [Time] Start of the range to evaluate the schedule in. This is exclusive.
358
+ # @param end_at [Time] End of the range to evaluate the schedule in. This is inclusive.
359
+ # @param overlap [OverlapPolicy] Overlap policy.
360
+ def initialize(
361
+ start_at:,
362
+ end_at:,
363
+ overlap: nil
364
+ )
365
+ super
366
+ end
367
+
368
+ # @!visibility private
369
+ def _to_proto
370
+ Api::Schedule::V1::BackfillRequest.new(
371
+ start_time: Internal::ProtoUtils.time_to_timestamp(start_at),
372
+ end_time: Internal::ProtoUtils.time_to_timestamp(end_at),
373
+ overlap_policy: overlap || Api::Enums::V1::ScheduleOverlapPolicy::SCHEDULE_OVERLAP_POLICY_UNSPECIFIED
374
+ )
375
+ end
376
+ end
377
+
378
+ # Base module mixed in by specific action executions.
379
+ module ActionExecution
380
+ StartWorkflow = Data.define(
381
+ :workflow_id,
382
+ :first_execution_run_id
383
+ )
384
+
385
+ # Execution of a scheduled workflow start.
386
+ #
387
+ # @!attribute workflow_id
388
+ # @return [String] Workflow ID.
389
+ # @!attribute first_execution_run_id
390
+ # @return [String] Workflow run ID.
391
+ class StartWorkflow
392
+ include ActionExecution
393
+
394
+ # @!visibility private
395
+ def initialize(raw_execution:)
396
+ # steep:ignore:start
397
+ super(
398
+ workflow_id: raw_execution.workflow_id,
399
+ first_execution_run_id: raw_execution.run_id
400
+ )
401
+ # steep:ignore:end
402
+ end
403
+ end
404
+ end
405
+
406
+ ActionResult = Data.define(
407
+ :scheduled_at,
408
+ :started_at,
409
+ :action
410
+ )
411
+
412
+ # Information about when an action took place.
413
+ #
414
+ # @!attribute scheduled_at
415
+ # @return [Time] Scheduled time of the action including jitter.
416
+ # @!attribute started_at
417
+ # @return [Time] When the action actually started.
418
+ # @!attribute action
419
+ # @return [ActionExecution] Action that took place.
420
+ class ActionResult
421
+ # @!visibility private
422
+ def initialize(raw_result:)
423
+ # steep:ignore:start
424
+ super(
425
+ scheduled_at: Internal::ProtoUtils.timestamp_to_time(raw_result.schedule_time),
426
+ started_at: Internal::ProtoUtils.timestamp_to_time(raw_result.actual_time),
427
+ action: ActionExecution::StartWorkflow.new(raw_execution: raw_result.start_workflow_result)
428
+ )
429
+ # steep:ignore:end
430
+ end
431
+ end
432
+
433
+ Spec = Data.define(
434
+ :calendars,
435
+ :intervals,
436
+ :cron_expressions,
437
+ :skip,
438
+ :start_at,
439
+ :end_at,
440
+ :jitter,
441
+ :time_zone_name
442
+ )
443
+
444
+ # Specification of the times scheduled actions may occur.
445
+ #
446
+ # The times are the union of {calendars}, {intervals}, and {cron_expressions} excluding anything in {skip}.
447
+ #
448
+ # @!attribute calendars
449
+ # @return [Array<Calendar>] Calendar-based specification of times.
450
+ # @!attribute intervals
451
+ # @return [Array<Interval>] Interval-based specification of times.
452
+ # @!attribute cron_expressions
453
+ # @return [Array<String>] Cron-based specification of times. This is provided for easy migration
454
+ # from legacy string-based cron scheduling. New uses should use `calendars` instead. These expressions will be
455
+ # translated to calendar-based specifications on the server.
456
+ # @!attribute skip
457
+ # @return [Array<Calendar>] Set of matching calendar times that will be skipped.
458
+ # @!attribute start_at
459
+ # @return [Time, nil] Time before which any matching times will be skipped.
460
+ # @!attribute end_at
461
+ # @return [Time, nil] Time after which any matching times will be skipped.
462
+ # @!attribute jitter
463
+ # @return [Float, nil] Jitter to apply each action. An action's scheduled time will be incremented by a random
464
+ # value between 0 and this value if present (but not past the next schedule).
465
+ # @!attribute time_zone_name
466
+ # @return [String, nil] IANA time zone name, for example `US/Central`.
467
+ class Spec
468
+ # @!visibility private
469
+ def self._from_proto(raw_spec)
470
+ Schedule::Spec.new(
471
+ calendars: raw_spec.structured_calendar.map { |c| Calendar._from_proto(c) },
472
+ intervals: raw_spec.interval.map { |c| Interval._from_proto(c) },
473
+ cron_expressions: raw_spec.cron_string.to_a,
474
+ skip: raw_spec.exclude_structured_calendar.map { |c| Calendar._from_proto(c) },
475
+ start_at: Internal::ProtoUtils.timestamp_to_time(raw_spec.start_time),
476
+ end_at: Internal::ProtoUtils.timestamp_to_time(raw_spec.end_time),
477
+ jitter: Internal::ProtoUtils.duration_to_seconds(raw_spec.jitter),
478
+ time_zone_name: Internal::ProtoUtils.string_or(raw_spec.timezone_name)
479
+ )
480
+ end
481
+
482
+ # Create a spec.
483
+ #
484
+ # @param calendars [Array<Calendar>] Calendar-based specification of times.
485
+ # @param intervals [Array<Interval>] Interval-based specification of times.
486
+ # @param cron_expressions [Array<String>] Cron-based specification of times. This is provided for easy migration
487
+ # from legacy string-based cron scheduling. New uses should use `calendars` instead. These expressions will be
488
+ # translated to calendar-based specifications on the server.
489
+ # @param skip [Array<Calendar>] Set of matching calendar times that will be skipped.
490
+ # @param start_at [Time, nil] Time before which any matching times will be skipped.
491
+ # @param end_at [Time, nil] Time after which any matching times will be skipped.
492
+ # @param jitter [Float, nil] Jitter to apply each action. An action's scheduled time will be incremented by a
493
+ # random value between 0 and this value if present (but not past the next schedule).
494
+ # @param time_zone_name [String, nil] IANA time zone name, for example `US/Central`.
495
+ def initialize(
496
+ calendars: [],
497
+ intervals: [],
498
+ cron_expressions: [],
499
+ skip: [],
500
+ start_at: nil,
501
+ end_at: nil,
502
+ jitter: nil,
503
+ time_zone_name: nil
504
+ )
505
+ super
506
+ end
507
+
508
+ # @!visibility private
509
+ def _to_proto
510
+ Api::Schedule::V1::ScheduleSpec.new(
511
+ structured_calendar: calendars.map(&:_to_proto),
512
+ cron_string: cron_expressions,
513
+ interval: intervals.map(&:_to_proto),
514
+ exclude_structured_calendar: skip.map(&:_to_proto),
515
+ start_time: Internal::ProtoUtils.time_to_timestamp(start_at),
516
+ end_time: Internal::ProtoUtils.time_to_timestamp(end_at),
517
+ jitter: Internal::ProtoUtils.seconds_to_duration(jitter),
518
+ timezone_name: time_zone_name || ''
519
+ )
520
+ end
521
+
522
+ Calendar = Data.define( # rubocop:disable Layout/ClassStructure
523
+ :second,
524
+ :minute,
525
+ :hour,
526
+ :day_of_month,
527
+ :month,
528
+ :year,
529
+ :day_of_week,
530
+ :comment
531
+ )
532
+
533
+ # Specification relative to calendar time when to run an action.
534
+ #
535
+ # A timestamp matches if at least one range of each field matches except for year. If year is missing, that
536
+ # means all years match. For all fields besides year, at least one range must be present to match anything.
537
+ #
538
+ # @!attribute second
539
+ # @return [Array<Range>] Second range to match, 0-59. Default matches 0.
540
+ # @!attribute minute
541
+ # @return [Array<Range>] Minute range to match, 0-59. Default matches 0.
542
+ # @!attribute hour
543
+ # @return [Array<Range>] Hour range to match, 0-23. Default matches 0.
544
+ # @!attribute day_of_month
545
+ # @return [Array<Range>] Day of month range to match, 1-31. Default matches all days.
546
+ # @!attribute month
547
+ # @return [Array<Range>] Month range to match, 1-12. Default matches all months.
548
+ # @!attribute year
549
+ # @return [Array<Range>] Optional year range to match. Default of empty matches all years.
550
+ # @!attribute day_of_week
551
+ # @return [Array<Range>] Day of week range to match, 0-6, 0 is Sunday. Default matches all days.
552
+ # @!attribute comment
553
+ # @return [String, nil] Description of this schedule.
554
+ class Calendar
555
+ # @!visibility private
556
+ def self._from_proto(raw_cal)
557
+ Calendar.new(
558
+ second: Range._from_protos(raw_cal.second),
559
+ minute: Range._from_protos(raw_cal.minute),
560
+ hour: Range._from_protos(raw_cal.hour),
561
+ day_of_month: Range._from_protos(raw_cal.day_of_month),
562
+ month: Range._from_protos(raw_cal.month),
563
+ year: Range._from_protos(raw_cal.year),
564
+ day_of_week: Range._from_protos(raw_cal.day_of_week),
565
+ comment: Internal::ProtoUtils.string_or(raw_cal.comment)
566
+ )
567
+ end
568
+
569
+ # Create a calendar spec.
570
+ #
571
+ # @param second [Array<Range>] Second range to match, 0-59. Default matches 0.
572
+ # @param minute [Array<Range>] Minute range to match, 0-59. Default matches 0.
573
+ # @param hour [Array<Range>] Hour range to match, 0-23. Default matches 0.
574
+ # @param day_of_month [Array<Range>] Day of month range to match, 1-31. Default matches all days.
575
+ # @param month [Array<Range>] Month range to match, 1-12. Default matches all months.
576
+ # @param year [Array<Range>] Optional year range to match. Default of empty matches all years.
577
+ # @param day_of_week [Array<Range>] Day of week range to match, 0-6, 0 is Sunday. Default matches all days.
578
+ # @param comment [String, nil] Description of this schedule.
579
+ def initialize(
580
+ second: [Range.new(0)],
581
+ minute: [Range.new(0)],
582
+ hour: [Range.new(0)],
583
+ day_of_month: [Range.new(1, 31)],
584
+ month: [Range.new(1, 12)],
585
+ year: [],
586
+ day_of_week: [Range.new(0, 6)],
587
+ comment: nil
588
+ )
589
+ super
590
+ end
591
+
592
+ # @!visibility private
593
+ def _to_proto
594
+ Api::Schedule::V1::StructuredCalendarSpec.new(
595
+ second: Range._to_protos(second),
596
+ minute: Range._to_protos(minute),
597
+ hour: Range._to_protos(hour),
598
+ day_of_month: Range._to_protos(day_of_month),
599
+ month: Range._to_protos(month),
600
+ year: Range._to_protos(year),
601
+ day_of_week: Range._to_protos(day_of_week),
602
+ comment: comment || ''
603
+ )
604
+ end
605
+ end
606
+
607
+ Interval = Data.define(
608
+ :every,
609
+ :offset
610
+ )
611
+
612
+ # Specification for scheduling on an interval.
613
+ #
614
+ # Matches times expressed as epoch + (n * every) + offset.
615
+ #
616
+ # @!attribute every
617
+ # @return [Float] Period to repeat the interval.
618
+ # @!attribute offset
619
+ # @return [Float, nil] Fixed offset added to each interval period.
620
+ class Interval
621
+ # @!visibility private
622
+ def self._from_proto(raw_int)
623
+ Schedule::Spec::Interval.new(
624
+ every: Internal::ProtoUtils.duration_to_seconds(raw_int.interval) || raise, # Never nil
625
+ offset: Internal::ProtoUtils.duration_to_seconds(raw_int.phase)
626
+ )
627
+ end
628
+
629
+ # Create an interval spec.
630
+ #
631
+ # @param every [Float] Period to repeat the interval.
632
+ # @param offset [Float, nil] Fixed offset added to each interval period.
633
+ def initialize(every:, offset: nil)
634
+ super
635
+ end
636
+
637
+ # @!visibility private
638
+ def _to_proto
639
+ Api::Schedule::V1::IntervalSpec.new(
640
+ interval: Internal::ProtoUtils.seconds_to_duration(every),
641
+ phase: Internal::ProtoUtils.seconds_to_duration(offset)
642
+ )
643
+ end
644
+ end
645
+ end
646
+
647
+ Range = Data.define(
648
+ :start,
649
+ :finish,
650
+ :step
651
+ )
652
+
653
+ # Inclusive range for a schedule match value.
654
+ #
655
+ # @!attribute start
656
+ # @return [Integer] Inclusive start of the range.
657
+ # @!attribute finish
658
+ # @return [Integer] Inclusive end of the range. If unset or less than start, defaults to start.
659
+ # @!attribute step
660
+ # @return [Integer] Step to take between each value. Defaults as 1.
661
+ class Range
662
+ class << self
663
+ alias _original_new new
664
+
665
+ # Create inclusive range.
666
+ #
667
+ # @param start [Integer] Inclusive start of the range.
668
+ # @param finish [Integer] Inclusive end of the range. If unset or less than start, defaults to start.
669
+ # @param step [Integer] Step to take between each value. Defaults as 1.
670
+ def new(start, finish = [0, start].max, step = 1)
671
+ _original_new( # steep:ignore
672
+ start:,
673
+ finish:,
674
+ step:
675
+ )
676
+ end
677
+ end
678
+
679
+ # @!visibility private
680
+ def self._from_proto(raw_range)
681
+ Schedule::Range.new(
682
+ raw_range.start,
683
+ raw_range.end,
684
+ raw_range.step
685
+ )
686
+ end
687
+
688
+ # @!visibility private
689
+ def self._from_protos(raw_ranges)
690
+ raw_ranges.map { |v| _from_proto(v) }
691
+ end
692
+
693
+ # @!visibility private
694
+ def self._to_protos(ranges)
695
+ ranges.map(&:_to_proto)
696
+ end
697
+
698
+ # @!visibility private
699
+ def _to_proto
700
+ Api::Schedule::V1::Range.new(
701
+ start:,
702
+ end: finish,
703
+ step:
704
+ )
705
+ end
706
+ end
707
+
708
+ Policy = Data.define(
709
+ :overlap,
710
+ :catchup_window,
711
+ :pause_on_failure
712
+ )
713
+
714
+ # Policies of a schedule.
715
+ #
716
+ # @!attribute overlap
717
+ # @return [OverlapPolicy] Controls what happens when an action is started while another is still running.
718
+ # @!attribute catchup_window
719
+ # @return [Float] After a Temporal server is unavailable, amount of time in the past to execute missed actions.
720
+ # @!attribute pause_on_failure
721
+ # @return [Boolean] Whether to pause the schedule if an action fails or times out. Note: For workflows, this
722
+ # only applies after all retries have been exhausted.
723
+ class Policy
724
+ # @!visibility private
725
+ def self._from_proto(raw_policies)
726
+ Schedule::Policy.new(
727
+ overlap: Internal::ProtoUtils.enum_to_int(Api::Enums::V1::ScheduleOverlapPolicy,
728
+ raw_policies.overlap_policy,
729
+ zero_means_nil: true),
730
+ catchup_window: Internal::ProtoUtils.duration_to_seconds(raw_policies.catchup_window) || raise, # Never nil
731
+ pause_on_failure: raw_policies.pause_on_failure
732
+ )
733
+ end
734
+
735
+ # Create a schedule policy.
736
+ #
737
+ # @param overlap [OverlapPolicy] Controls what happens when an action is started while another is still running.
738
+ # @param catchup_window [Float] After a Temporal server is unavailable, amount of time in the past to execute
739
+ # missed actions.
740
+ # @param pause_on_failure [Boolean] Whether to pause the schedule if an action fails or times out. Note: For
741
+ # workflows, this only applies after all retries have been exhausted.
742
+ def initialize(
743
+ overlap: OverlapPolicy::SKIP,
744
+ catchup_window: 365 * 24 * 60 * 60.0,
745
+ pause_on_failure: false
746
+ )
747
+ super
748
+ end
749
+
750
+ # @!visibility private
751
+ def _to_proto
752
+ Api::Schedule::V1::SchedulePolicies.new(
753
+ overlap_policy: overlap,
754
+ catchup_window: Internal::ProtoUtils.seconds_to_duration(catchup_window),
755
+ pause_on_failure:
756
+ )
757
+ end
758
+ end
759
+
760
+ State = Data.define(
761
+ :note,
762
+ :paused,
763
+ :limited_actions,
764
+ :remaining_actions
765
+ )
766
+
767
+ # State of a schedule.
768
+ #
769
+ # @!attribute note
770
+ # @return [String, nil] Human readable message for the schedule. The system may overwrite this value on certain
771
+ # conditions like pause-on-failure.
772
+ # @!attribute paused
773
+ # @return [Boolean] Whether the schedule is paused.
774
+ # @!attribute limited_actions
775
+ # @return [Boolean] If true, remaining actions will be decremented for each action taken. On schedule create,
776
+ # this must be set to true if `remaining_actions` is non-zero and left false if `remaining_actions` is zero.
777
+ # @!attribute remaining_actions
778
+ # @return [Integer] Actions remaining on this schedule. Once this number hits 0, no further actions are
779
+ # scheduled automatically.
780
+ class State
781
+ # @!visibility private
782
+ def self._from_proto(raw_state)
783
+ Schedule::State.new(
784
+ note: Internal::ProtoUtils.string_or(raw_state.notes),
785
+ paused: raw_state.paused,
786
+ limited_actions: raw_state.limited_actions,
787
+ remaining_actions: raw_state.remaining_actions
788
+ )
789
+ end
790
+
791
+ # Create a schedule state.
792
+ #
793
+ # @param note [String, nil] Human readable message for the schedule. The system may overwrite this value on
794
+ # certain conditions like pause-on-failure.
795
+ # @param paused [Boolean] Whether the schedule is paused.
796
+ # @param limited_actions [Boolean] If true, remaining actions will be decremented for each action taken. On
797
+ # schedule create, this must be set to true if `remaining_actions` is non-zero and left false if
798
+ # `remaining_actions` is zero.
799
+ # @param remaining_actions [Integer] Actions remaining on this schedule. Once this number hits 0, no further
800
+ # actions are scheduled automatically.
801
+ def initialize(
802
+ note: nil,
803
+ paused: false,
804
+ limited_actions: false,
805
+ remaining_actions: 0
806
+ )
807
+ super
808
+ end
809
+
810
+ # @!visibility private
811
+ def _to_proto
812
+ Api::Schedule::V1::ScheduleState.new(
813
+ notes: note || '',
814
+ paused:,
815
+ limited_actions:,
816
+ remaining_actions:
817
+ )
818
+ end
819
+ end
820
+
821
+ Update = Data.define(
822
+ :schedule,
823
+ :search_attributes
824
+ )
825
+
826
+ # Result of an update callback for {ScheduleHandle.update}.
827
+ #
828
+ # @!attribute schedule
829
+ # @return [Schedule] Schedule to update.
830
+ # @!attribute search_attributes
831
+ # @return [SearchAttributes, nil] Search attributes to update to.
832
+ class Update
833
+ # Create an update callback result.
834
+ #
835
+ # @param schedule [Schedule] Schedule to update.
836
+ # @param search_attributes [SearchAttributes, nil] Search attributes to update to.
837
+ def initialize(schedule:, search_attributes: nil)
838
+ super
839
+ end
840
+
841
+ # Parameter for an update callback for {ScheduleHandle.update}.
842
+ #
843
+ # @!attribute description
844
+ # @return [Description] Current description of the schedule.
845
+ Input = Data.define( # rubocop:disable Layout/ClassStructure
846
+ :description
847
+ )
848
+ end
849
+
850
+ module List
851
+ Description = Data.define(
852
+ :id,
853
+ :schedule,
854
+ :info,
855
+ :raw_entry
856
+ )
857
+
858
+ # Description of a listed schedule.
859
+ #
860
+ # @!attribute id
861
+ # @return [String] ID of the schedule.
862
+ # @!attribute schedule
863
+ # @return [Schedule, nil] Schedule details that can be mutated. This may not be present in older Temporal
864
+ # servers without advanced visibility.
865
+ # @!attribute info
866
+ # @return [Info, nil] Information about the schedule. This may not be present in older Temporal servers
867
+ # without advanced visibility.
868
+ # @!attribute raw_entry
869
+ # @return [Api::Schedule::V1::ScheduleListEntry] Raw description of the schedule.
870
+ class Description
871
+ # @!visibility private
872
+ def initialize(raw_entry:, data_converter:)
873
+ @memo = Internal::ProtoUtils::LazyMemo.new(raw_entry.memo, data_converter)
874
+ @search_attributes = Internal::ProtoUtils::LazySearchAttributes.new(raw_entry.search_attributes)
875
+ # steep:ignore:start
876
+ super(
877
+ id: raw_entry.schedule_id,
878
+ schedule: (Schedule.new(raw_info: raw_entry.info) if raw_entry.info),
879
+ info: (Info.new(raw_info: raw_entry.info) if raw_entry.info),
880
+ raw_entry:
881
+ )
882
+ # steep:ignore:end
883
+ end
884
+
885
+ # @return [Hash<String, Object>, nil] Memo for the schedule, converted lazily on first call.
886
+ def memo
887
+ @memo.get
888
+ end
889
+
890
+ # @return [Search attributes, nil] Search attributes for the schedule, converted lazily on first call.
891
+ def search_attributes
892
+ @search_attributes.get
893
+ end
894
+ end
895
+
896
+ Schedule = Data.define(
897
+ :action,
898
+ :spec,
899
+ :state
900
+ )
901
+
902
+ # Details for a listed schedule.
903
+ #
904
+ # @!attribute action
905
+ # @return [Action] Action taken when scheduled.
906
+ # @!attribute spec
907
+ # @return [Spec] When the action is taken.
908
+ # @!attribute state
909
+ # @return [State] State of the schedule.
910
+ class Schedule
911
+ # @!visibility private
912
+ def initialize(raw_info:)
913
+ raise 'Unknown action on schedule' unless raw_info.workflow_type
914
+
915
+ # steep:ignore:start
916
+ super(
917
+ action: Action::StartWorkflow.new(workflow: raw_info.workflow_type.name),
918
+ spec: Spec._from_proto(raw_info.spec),
919
+ state: State.new(raw_info:)
920
+ )
921
+ # steep:ignore:end
922
+ end
923
+ end
924
+
925
+ # Base module mixed in by specific actions a listed schedule can take.
926
+ module Action
927
+ StartWorkflow = Data.define(
928
+ :workflow
929
+ )
930
+
931
+ # Action to start a workflow on a listed schedule.
932
+ #
933
+ # @!attribute workflow
934
+ # @return [String] Workflow type name.
935
+ class StartWorkflow
936
+ include Action
937
+ end
938
+ end
939
+
940
+ Info = Data.define(
941
+ :recent_actions,
942
+ :next_action_times
943
+ )
944
+
945
+ # Information about a listed schedule.
946
+ #
947
+ # @!attribute recent_actions
948
+ # @return [Array<ActionResult>] Most recent actions, oldest first. This may be a smaller amount than present
949
+ # on {Temporalio::Client::Schedule::Info.recent_actions}.
950
+ # @!attribute next_action_times
951
+ # @return [Array<Time>] Next scheduled action times. This may be a smaller amount than present on
952
+ # {Temporalio::Client::Schedule::Info.next_action_times}.
953
+ class Info
954
+ # @!visibility private
955
+ def initialize(raw_info:)
956
+ # steep:ignore:start
957
+ super(
958
+ recent_actions: raw_info.recent_actions.map { |a| ActionResult.new(raw_result: a) },
959
+ next_action_times: raw_info.future_action_times.map { |t| Internal::ProtoUtils.timestamp_to_time(t) }
960
+ )
961
+ # steep:ignore:end
962
+ end
963
+ end
964
+
965
+ State = Data.define(
966
+ :note,
967
+ :paused
968
+ )
969
+
970
+ # State of a listed schedule.
971
+ #
972
+ # @!attribute note
973
+ # @return [String, nil] Human readable message for the schedule. The system may overwrite this value on
974
+ # certain conditions like pause-on-failure.
975
+ # @!attribute paused
976
+ # @return [Boolean] Whether the schedule is paused.
977
+ class State
978
+ # @!visibility private
979
+ def initialize(raw_info:)
980
+ # steep:ignore:start
981
+ super(
982
+ note: Internal::ProtoUtils.string_or(raw_info.notes),
983
+ paused: raw_info.paused
984
+ )
985
+ # steep:ignore:end
986
+ end
987
+ end
988
+ end
989
+ end
990
+ end
991
+ end