temporalio 0.0.1 → 0.0.2

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 (232) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +175 -4
  3. data/bridge/Cargo.lock +44 -21
  4. data/bridge/Cargo.toml +1 -0
  5. data/bridge/sdk-core/Cargo.toml +1 -1
  6. data/bridge/sdk-core/README.md +1 -4
  7. data/bridge/sdk-core/client/Cargo.toml +1 -1
  8. data/bridge/sdk-core/client/src/lib.rs +12 -20
  9. data/bridge/sdk-core/client/src/raw.rs +9 -8
  10. data/bridge/sdk-core/client/src/retry.rs +100 -23
  11. data/bridge/sdk-core/core/Cargo.toml +7 -7
  12. data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
  13. data/bridge/sdk-core/core/src/abstractions.rs +22 -22
  14. data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +146 -43
  15. data/bridge/sdk-core/core/src/core_tests/local_activities.rs +419 -9
  16. data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -89
  17. data/bridge/sdk-core/core/src/core_tests/workers.rs +2 -2
  18. data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
  19. data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +47 -27
  20. data/bridge/sdk-core/core/src/lib.rs +139 -32
  21. data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
  22. data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
  23. data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
  24. data/bridge/sdk-core/core/src/telemetry/metrics.rs +184 -139
  25. data/bridge/sdk-core/core/src/telemetry/mod.rs +310 -315
  26. data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +4 -3
  27. data/bridge/sdk-core/core/src/test_help/mod.rs +23 -9
  28. data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +12 -6
  29. data/bridge/sdk-core/core/src/worker/activities.rs +40 -23
  30. data/bridge/sdk-core/core/src/worker/client/mocks.rs +1 -1
  31. data/bridge/sdk-core/core/src/worker/client.rs +30 -4
  32. data/bridge/sdk-core/core/src/worker/mod.rs +23 -19
  33. data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +10 -19
  34. data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +99 -25
  35. data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -5
  36. data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -5
  37. data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +1 -5
  38. data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +3 -5
  39. data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +1 -5
  40. data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +2 -6
  41. data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +1 -5
  42. data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +24 -22
  43. data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +12 -38
  44. data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
  45. data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +1 -5
  46. data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -5
  47. data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -5
  48. data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +8 -2
  49. data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +1 -5
  50. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
  51. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +233 -217
  52. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +1 -6
  53. data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +4 -4
  54. data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +13 -5
  55. data/bridge/sdk-core/core/src/worker/workflow/mod.rs +86 -29
  56. data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
  57. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +56 -11
  58. data/bridge/sdk-core/core-api/Cargo.toml +4 -3
  59. data/bridge/sdk-core/core-api/src/lib.rs +1 -43
  60. data/bridge/sdk-core/core-api/src/telemetry.rs +147 -0
  61. data/bridge/sdk-core/core-api/src/worker.rs +13 -0
  62. data/bridge/sdk-core/etc/deps.svg +115 -140
  63. data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
  64. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
  65. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
  66. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
  67. data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -3
  68. data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
  69. data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
  70. data/bridge/sdk-core/protos/api_upstream/{temporal/api/update/v1/message.proto → build/tools.go} +6 -23
  71. data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
  72. data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
  73. data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +20 -19
  74. data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
  75. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
  76. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -4
  77. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
  78. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +5 -3
  79. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +23 -2
  80. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/{cluster.proto → interaction_type.proto} +10 -11
  81. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
  82. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
  83. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
  84. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
  85. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
  86. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +2 -13
  87. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
  88. data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
  89. data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
  90. data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
  91. data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +26 -19
  92. data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -0
  93. data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -2
  94. data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +21 -61
  95. data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
  96. data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
  97. data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
  98. data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
  99. data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
  100. data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
  101. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
  102. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -16
  103. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +17 -3
  104. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  105. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +8 -1
  106. data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
  107. data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
  108. data/bridge/sdk-core/sdk/Cargo.toml +2 -2
  109. data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
  110. data/bridge/sdk-core/sdk/src/lib.rs +7 -5
  111. data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
  112. data/bridge/sdk-core/sdk/src/workflow_future.rs +3 -7
  113. data/bridge/sdk-core/sdk-core-protos/Cargo.toml +1 -1
  114. data/bridge/sdk-core/sdk-core-protos/build.rs +0 -1
  115. data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +65 -18
  116. data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +22 -22
  117. data/bridge/sdk-core/sdk-core-protos/src/lib.rs +104 -44
  118. data/bridge/sdk-core/test-utils/Cargo.toml +2 -1
  119. data/bridge/sdk-core/test-utils/src/lib.rs +81 -29
  120. data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -2
  121. data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
  122. data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -13
  123. data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +167 -13
  124. data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -0
  125. data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +106 -20
  126. data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +18 -8
  127. data/bridge/sdk-core/tests/main.rs +6 -4
  128. data/bridge/src/connection.rs +81 -62
  129. data/bridge/src/lib.rs +92 -33
  130. data/bridge/src/runtime.rs +9 -2
  131. data/bridge/src/worker.rs +53 -2
  132. data/lib/bridge.so +0 -0
  133. data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
  134. data/lib/gen/temporal/api/command/v1/message_pb.rb +17 -9
  135. data/lib/gen/temporal/api/common/v1/message_pb.rb +1 -1
  136. data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
  137. data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -1
  138. data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
  139. data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +3 -2
  140. data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +7 -1
  141. data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +25 -0
  142. data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
  143. data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
  144. data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
  145. data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
  146. data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
  147. data/lib/gen/temporal/api/enums/v1/update_pb.rb +1 -6
  148. data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
  149. data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
  150. data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
  151. data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
  152. data/lib/gen/temporal/api/history/v1/message_pb.rb +19 -18
  153. data/lib/gen/temporal/api/interaction/v1/message_pb.rb +49 -0
  154. data/lib/gen/temporal/api/namespace/v1/message_pb.rb +1 -1
  155. data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +11 -51
  156. data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
  157. data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
  158. data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
  159. data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
  160. data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
  161. data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
  162. data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
  163. data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +27 -10
  164. data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
  165. data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +1 -0
  166. data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +5 -1
  167. data/lib/temporalio/activity/context.rb +97 -0
  168. data/lib/temporalio/activity/info.rb +67 -0
  169. data/lib/temporalio/activity.rb +85 -0
  170. data/lib/temporalio/bridge/error.rb +8 -0
  171. data/lib/temporalio/bridge.rb +14 -0
  172. data/lib/{temporal → temporalio}/client/implementation.rb +49 -48
  173. data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
  174. data/lib/{temporal → temporalio}/client.rb +19 -32
  175. data/lib/{temporal → temporalio}/connection.rb +238 -223
  176. data/lib/{temporal → temporalio}/data_converter.rb +76 -35
  177. data/lib/{temporal → temporalio}/error/failure.rb +6 -6
  178. data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
  179. data/lib/{temporal → temporalio}/errors.rb +19 -1
  180. data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
  181. data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
  182. data/lib/temporalio/failure_converter.rb +7 -0
  183. data/lib/{temporal → temporalio}/interceptor/chain.rb +2 -1
  184. data/lib/{temporal → temporalio}/interceptor/client.rb +22 -1
  185. data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
  186. data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
  187. data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
  188. data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
  189. data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
  190. data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
  191. data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
  192. data/lib/temporalio/payload_converter.rb +14 -0
  193. data/lib/{temporal → temporalio}/retry_policy.rb +4 -4
  194. data/lib/{temporal → temporalio}/retry_state.rb +1 -1
  195. data/lib/temporalio/runtime.rb +25 -0
  196. data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
  197. data/lib/temporalio/version.rb +3 -0
  198. data/lib/temporalio/worker/activity_runner.rb +92 -0
  199. data/lib/temporalio/worker/activity_worker.rb +138 -0
  200. data/lib/temporalio/worker/reactor.rb +46 -0
  201. data/lib/temporalio/worker/runner.rb +63 -0
  202. data/lib/temporalio/worker/sync_worker.rb +88 -0
  203. data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
  204. data/lib/temporalio/worker.rb +198 -0
  205. data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
  206. data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
  207. data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
  208. data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
  209. data/lib/temporalio.rb +12 -3
  210. data/temporalio.gemspec +7 -3
  211. metadata +79 -56
  212. data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
  213. data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
  214. data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
  215. data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
  216. data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
  217. data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
  218. data/bridge/sdk-core/core/src/log_export.rs +0 -62
  219. data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
  220. data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
  221. data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
  222. data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
  223. data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
  224. data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
  225. data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
  226. data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -26
  227. data/lib/temporal/bridge.rb +0 -14
  228. data/lib/temporal/failure_converter.rb +0 -8
  229. data/lib/temporal/payload_converter.rb +0 -14
  230. data/lib/temporal/runtime.rb +0 -22
  231. data/lib/temporal/version.rb +0 -3
  232. data/lib/temporal.rb +0 -8
@@ -14,6 +14,7 @@ require 'temporal/api/enums/v1/task_queue_pb'
14
14
  require 'temporal/api/enums/v1/update_pb'
15
15
  require 'temporal/api/common/v1/message_pb'
16
16
  require 'temporal/api/history/v1/message_pb'
17
+ require 'temporal/api/interaction/v1/message_pb'
17
18
  require 'temporal/api/workflow/v1/message_pb'
18
19
  require 'temporal/api/command/v1/message_pb'
19
20
  require 'temporal/api/failure/v1/message_pb'
@@ -23,7 +24,6 @@ require 'temporal/api/query/v1/message_pb'
23
24
  require 'temporal/api/replication/v1/message_pb'
24
25
  require 'temporal/api/schedule/v1/message_pb'
25
26
  require 'temporal/api/taskqueue/v1/message_pb'
26
- require 'temporal/api/update/v1/message_pb'
27
27
  require 'temporal/api/version/v1/message_pb'
28
28
  require 'temporal/api/batch/v1/message_pb'
29
29
  require 'google/protobuf/duration_pb'
@@ -143,7 +143,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
143
143
  optional :task_queue, :message, 2, "temporal.api.taskqueue.v1.TaskQueue"
144
144
  optional :identity, :string, 3
145
145
  optional :binary_checksum, :string, 4
146
- optional :worker_versioning_build_id, :string, 5
146
+ optional :worker_versioning_id, :message, 5, "temporal.api.taskqueue.v1.VersionId"
147
147
  end
148
148
  add_message "temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse" do
149
149
  optional :task_token, :bytes, 1
@@ -160,6 +160,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
160
160
  optional :scheduled_time, :message, 12, "google.protobuf.Timestamp"
161
161
  optional :started_time, :message, 13, "google.protobuf.Timestamp"
162
162
  map :queries, :string, :message, 14, "temporal.api.query.v1.WorkflowQuery"
163
+ repeated :interactions, :message, 15, "temporal.api.interaction.v1.Invocation"
163
164
  end
164
165
  add_message "temporal.api.workflowservice.v1.RespondWorkflowTaskCompletedRequest" do
165
166
  optional :task_token, :bytes, 1
@@ -171,10 +172,12 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
171
172
  optional :binary_checksum, :string, 7
172
173
  map :query_results, :string, :message, 8, "temporal.api.query.v1.WorkflowQueryResult"
173
174
  optional :namespace, :string, 9
175
+ optional :worker_versioning_id, :message, 10, "temporal.api.taskqueue.v1.VersionId"
174
176
  end
175
177
  add_message "temporal.api.workflowservice.v1.RespondWorkflowTaskCompletedResponse" do
176
178
  optional :workflow_task, :message, 1, "temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse"
177
179
  repeated :activity_tasks, :message, 2, "temporal.api.workflowservice.v1.PollActivityTaskQueueResponse"
180
+ optional :reset_history_event_id, :int64, 3
178
181
  end
179
182
  add_message "temporal.api.workflowservice.v1.RespondWorkflowTaskFailedRequest" do
180
183
  optional :task_token, :bytes, 1
@@ -191,7 +194,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
191
194
  optional :task_queue, :message, 2, "temporal.api.taskqueue.v1.TaskQueue"
192
195
  optional :identity, :string, 3
193
196
  optional :task_queue_metadata, :message, 4, "temporal.api.taskqueue.v1.TaskQueueMetadata"
194
- optional :worker_versioning_build_id, :string, 5
197
+ optional :worker_versioning_id, :message, 5, "temporal.api.taskqueue.v1.VersionId"
195
198
  end
196
199
  add_message "temporal.api.workflowservice.v1.PollActivityTaskQueueResponse" do
197
200
  optional :task_token, :bytes, 1
@@ -357,6 +360,12 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
357
360
  end
358
361
  add_message "temporal.api.workflowservice.v1.TerminateWorkflowExecutionResponse" do
359
362
  end
363
+ add_message "temporal.api.workflowservice.v1.DeleteWorkflowExecutionRequest" do
364
+ optional :namespace, :string, 1
365
+ optional :workflow_execution, :message, 2, "temporal.api.common.v1.WorkflowExecution"
366
+ end
367
+ add_message "temporal.api.workflowservice.v1.DeleteWorkflowExecutionResponse" do
368
+ end
360
369
  add_message "temporal.api.workflowservice.v1.ListOpenWorkflowExecutionsRequest" do
361
370
  optional :namespace, :string, 1
362
371
  optional :maximum_page_size, :int32, 2
@@ -498,6 +507,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
498
507
  optional :activity_failure_include_heartbeat, :bool, 3
499
508
  optional :supports_schedules, :bool, 4
500
509
  optional :encoded_failure_attributes, :bool, 5
510
+ optional :build_id_based_versioning, :bool, 6
511
+ optional :upsert_memo, :bool, 7
501
512
  end
502
513
  add_message "temporal.api.workflowservice.v1.ListTaskQueuePartitionsRequest" do
503
514
  optional :namespace, :string, 1
@@ -599,30 +610,32 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
599
610
  optional :namespace, :string, 3
600
611
  optional :workflow_execution, :message, 4, "temporal.api.common.v1.WorkflowExecution"
601
612
  optional :first_execution_run_id, :string, 5
602
- optional :update, :message, 6, "temporal.api.update.v1.WorkflowUpdate"
613
+ optional :identity, :string, 6
614
+ optional :input, :message, 7, "temporal.api.interaction.v1.Input"
603
615
  end
604
616
  add_message "temporal.api.workflowservice.v1.UpdateWorkflowResponse" do
605
617
  optional :update_token, :bytes, 1
606
- oneof :result do
607
- optional :success, :message, 2, "temporal.api.common.v1.Payloads"
608
- optional :failure, :message, 3, "temporal.api.failure.v1.Failure"
609
- end
618
+ optional :output, :message, 2, "temporal.api.interaction.v1.Output"
610
619
  end
611
620
  add_message "temporal.api.workflowservice.v1.StartBatchOperationRequest" do
612
621
  optional :namespace, :string, 1
613
622
  optional :visibility_query, :string, 2
623
+ optional :job_id, :string, 3
624
+ optional :reason, :string, 4
614
625
  oneof :operation do
615
626
  optional :termination_operation, :message, 10, "temporal.api.batch.v1.BatchOperationTermination"
616
627
  optional :signal_operation, :message, 11, "temporal.api.batch.v1.BatchOperationSignal"
617
628
  optional :cancellation_operation, :message, 12, "temporal.api.batch.v1.BatchOperationCancellation"
629
+ optional :deletion_operation, :message, 13, "temporal.api.batch.v1.BatchOperationDeletion"
618
630
  end
619
631
  end
620
632
  add_message "temporal.api.workflowservice.v1.StartBatchOperationResponse" do
621
- optional :job_id, :string, 1
622
633
  end
623
634
  add_message "temporal.api.workflowservice.v1.StopBatchOperationRequest" do
624
635
  optional :namespace, :string, 1
625
636
  optional :job_id, :string, 2
637
+ optional :reason, :string, 3
638
+ optional :identity, :string, 4
626
639
  end
627
640
  add_message "temporal.api.workflowservice.v1.StopBatchOperationResponse" do
628
641
  end
@@ -639,6 +652,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
639
652
  optional :total_operation_count, :int64, 6
640
653
  optional :complete_operation_count, :int64, 7
641
654
  optional :failure_operation_count, :int64, 8
655
+ optional :identity, :string, 9
656
+ optional :reason, :string, 10
642
657
  end
643
658
  add_message "temporal.api.workflowservice.v1.ListBatchOperationsRequest" do
644
659
  optional :namespace, :string, 1
@@ -652,7 +667,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
652
667
  end
653
668
  end
654
669
 
655
- module Temporal
670
+ module Temporalio
656
671
  module Api
657
672
  module WorkflowService
658
673
  module V1
@@ -706,6 +721,8 @@ module Temporal
706
721
  ResetWorkflowExecutionResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.ResetWorkflowExecutionResponse").msgclass
707
722
  TerminateWorkflowExecutionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.TerminateWorkflowExecutionRequest").msgclass
708
723
  TerminateWorkflowExecutionResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.TerminateWorkflowExecutionResponse").msgclass
724
+ DeleteWorkflowExecutionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.DeleteWorkflowExecutionRequest").msgclass
725
+ DeleteWorkflowExecutionResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.DeleteWorkflowExecutionResponse").msgclass
709
726
  ListOpenWorkflowExecutionsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.ListOpenWorkflowExecutionsRequest").msgclass
710
727
  ListOpenWorkflowExecutionsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.ListOpenWorkflowExecutionsResponse").msgclass
711
728
  ListClosedWorkflowExecutionsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.workflowservice.v1.ListClosedWorkflowExecutionsRequest").msgclass
@@ -10,7 +10,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
10
10
  end
11
11
  end
12
12
 
13
- module Temporal
13
+ module Temporalio
14
14
  module Api
15
15
  module WorkflowService
16
16
  module V1
@@ -61,6 +61,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
61
61
  optional :cron_schedule_to_schedule_interval, :message, 20, "google.protobuf.Duration"
62
62
  optional :memo, :message, 21, "temporal.api.common.v1.Memo"
63
63
  optional :search_attributes, :message, 22, "temporal.api.common.v1.SearchAttributes"
64
+ optional :start_time, :message, 23, "google.protobuf.Timestamp"
64
65
  end
65
66
  add_message "coresdk.workflow_activation.FireTimer" do
66
67
  optional :seq, :uint32, 1
@@ -33,6 +33,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
33
33
  optional :schedule_local_activity, :message, 16, "coresdk.workflow_commands.ScheduleLocalActivity"
34
34
  optional :request_cancel_local_activity, :message, 17, "coresdk.workflow_commands.RequestCancelLocalActivity"
35
35
  optional :upsert_workflow_search_attributes, :message, 18, "coresdk.workflow_commands.UpsertWorkflowSearchAttributes"
36
+ optional :modify_workflow_properties, :message, 19, "coresdk.workflow_commands.ModifyWorkflowProperties"
36
37
  end
37
38
  end
38
39
  add_message "coresdk.workflow_commands.StartTimer" do
@@ -46,7 +47,6 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
46
47
  optional :seq, :uint32, 1
47
48
  optional :activity_id, :string, 2
48
49
  optional :activity_type, :string, 3
49
- optional :namespace, :string, 4
50
50
  optional :task_queue, :string, 5
51
51
  map :headers, :string, :message, 6, "temporal.api.common.v1.Payload"
52
52
  repeated :arguments, :message, 7, "temporal.api.common.v1.Payload"
@@ -157,6 +157,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
157
157
  add_message "coresdk.workflow_commands.UpsertWorkflowSearchAttributes" do
158
158
  map :search_attributes, :string, :message, 1, "temporal.api.common.v1.Payload"
159
159
  end
160
+ add_message "coresdk.workflow_commands.ModifyWorkflowProperties" do
161
+ optional :upserted_memo, :message, 1, "temporal.api.common.v1.Memo"
162
+ end
160
163
  add_enum "coresdk.workflow_commands.ActivityCancellationType" do
161
164
  value :TRY_CANCEL, 0
162
165
  value :WAIT_CANCELLATION_COMPLETED, 1
@@ -187,6 +190,7 @@ module Coresdk
187
190
  SignalExternalWorkflowExecution = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.SignalExternalWorkflowExecution").msgclass
188
191
  CancelSignalWorkflow = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.CancelSignalWorkflow").msgclass
189
192
  UpsertWorkflowSearchAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.UpsertWorkflowSearchAttributes").msgclass
193
+ ModifyWorkflowProperties = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.ModifyWorkflowProperties").msgclass
190
194
  ActivityCancellationType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.ActivityCancellationType").enummodule
191
195
  end
192
196
  end
@@ -0,0 +1,97 @@
1
+ require 'temporalio/error/failure'
2
+ require 'temporalio/errors'
3
+
4
+ module Temporalio
5
+ class Activity
6
+ # This class provides methods that can be called from activity classes.
7
+ class Context
8
+ # Information about the running activity.
9
+ #
10
+ # @return [Temporalio::Activity::Info]
11
+ attr_reader :info
12
+
13
+ # @api private
14
+ def initialize(info, heartbeat_proc, shielded: false)
15
+ @thread = Thread.current
16
+ @info = info
17
+ @heartbeat_proc = heartbeat_proc
18
+ @pending_cancellation = nil
19
+ @shielded = shielded
20
+ @mutex = Mutex.new
21
+ end
22
+
23
+ # Send a heartbeat for the current activity.
24
+ #
25
+ # @param details [Array<any>] Data to store with the heartbeat.
26
+ def heartbeat(*details)
27
+ heartbeat_proc.call(*details)
28
+ end
29
+
30
+ # Protect a part of activity's implementation from cancellations.
31
+ #
32
+ # Activity cancellations are implemented using the `Thread#raise`, which can unsafely
33
+ # terminate your implementation. To disable this behaviour make sure to wrap critical parts of
34
+ # your business logic in this method.
35
+ #
36
+ # For shielding a whole activity consider using {Temporalio::Activity.shielded!}.
37
+ #
38
+ # A cancellation that got requested while in a shielded block will not interrupt the execution
39
+ # and will raise a {Temporalio::Error::CancelledError} right after the block has finished.
40
+ #
41
+ # @yield Block to be protected from cancellations.
42
+ def shield(&block)
43
+ # The whole activity is shielded, called from a nested shield
44
+ # or while handling a CancelledError (in a rescue or ensure blocks)
45
+ return block.call if @shielded || cancelled?
46
+
47
+ if Thread.current != thread
48
+ # TODO: Use logger instead when implemented
49
+ warn "Activity shielding is not intended to be used outside of activity's thread."
50
+ return block.call
51
+ end
52
+
53
+ mutex.synchronize do
54
+ @shielded = true
55
+ result = block.call
56
+ # RBS: StandardError fallback is only needed to satisfy steep - https://github.com/soutaro/steep/issues/477
57
+ raise @pending_cancellation || StandardError if cancelled?
58
+
59
+ result
60
+ ensure # runs while still holding the lock
61
+ @shielded = false
62
+ end
63
+ end
64
+
65
+ # Whether a cancellation was ever requested on this activity.
66
+ #
67
+ # @return [Boolean] true if the activity has had a cancellation request, false otherwise.
68
+ def cancelled?
69
+ !!@pending_cancellation
70
+ end
71
+
72
+ # Cancel the running activity by raising a provided error.
73
+ #
74
+ # @param reason [String] Reason for cancellation.
75
+ # @param by_request [Boolean] Cancellation requested by the server or not.
76
+ #
77
+ # @api private
78
+ def cancel(reason, by_request: false)
79
+ error = Temporalio::Error::ActivityCancelled.new(reason, by_request)
80
+ @pending_cancellation = error
81
+
82
+ locked = mutex.try_lock
83
+ # @shielded inside the lock means the whole activity is shielded
84
+ if locked && !@shielded
85
+ thread.raise(error)
86
+ end
87
+ ensure
88
+ # only release the lock if we locked it
89
+ mutex.unlock if locked
90
+ end
91
+
92
+ private
93
+
94
+ attr_reader :thread, :heartbeat_proc, :mutex
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,67 @@
1
+ module Temporalio
2
+ class Activity
3
+ # Class containing information about an activity.
4
+ class Info < Struct.new(
5
+ :activity_id,
6
+ :activity_type,
7
+ :attempt,
8
+ :current_attempt_scheduled_time,
9
+ :heartbeat_details,
10
+ :heartbeat_timeout,
11
+ :local,
12
+ :schedule_to_close_timeout,
13
+ :scheduled_time,
14
+ :start_to_close_timeout,
15
+ :started_time,
16
+ :task_queue,
17
+ :task_token,
18
+ :workflow_id,
19
+ :workflow_namespace,
20
+ :workflow_run_id,
21
+ :workflow_type,
22
+ keyword_init: true,
23
+ )
24
+ # @!attribute [r] activity_id
25
+ # @return [String] Activity ID.
26
+ # @!attribute [r] activity_type
27
+ # @return [String] Name of the activity.
28
+ # @!attribute [r] attempt
29
+ # @return [Integer] Activity's execution attempt.
30
+ # @!attribute [r] current_attempt_scheduled_time
31
+ # @return [Time] Scheduled time of the current attempt.
32
+ # @!attribute [r] heartbeat_details
33
+ # @return [Array<any>] Details submitted with the last heartbeat.
34
+ # @!attribute [r] heartbeat_timeout
35
+ # @return [Float] Max time between heartbeats (in seconds).
36
+ # @!attribute [r] local
37
+ # @return [Boolean] Whether activity is local or not.
38
+ # @!attribute [r] schedule_to_close_timeout
39
+ # @return [Float] Max overall activity execution time (in seconds).
40
+ # @!attribute [r] scheduled_time
41
+ # @return [Time] Time when activity was first scheduled.
42
+ # @!attribute [r] start_to_close_timeout
43
+ # @return [Floaat] Max time of a single invocation (in seconds).
44
+ # @!attribute [r] started_time
45
+ # @return [Time] Time when activity was started.
46
+ # @!attribute [r] task_queue
47
+ # @return [String] Task queue on which the activity got scheduled.
48
+ # @!attribute [r] task_token
49
+ # @return [String] A token for completing the activity.
50
+ # @!attribute [r] workflow_id
51
+ # @return [String] Workflow ID.
52
+ # @!attribute [r] workflow_namespace
53
+ # @return [String] Workflow namespace.
54
+ # @!attribute [r] workflow_run_id
55
+ # @return [String] Workflow run ID.
56
+ # @!attribute [r] workflow_type
57
+ # @return [String] Name of the workflow.
58
+
59
+ # Whether activity is local or not
60
+ #
61
+ # @return [Boolean] True for local activities, falst otherwise.
62
+ def local?
63
+ local
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,85 @@
1
+ module Temporalio
2
+ # This is an abstract superclass for implementing activities.
3
+ #
4
+ # Temporal SDK users are expected to subclass it and implement the {#execute} method by adding
5
+ # their desired business logic.
6
+ #
7
+ # @abstract
8
+ #
9
+ # @example "Hello World" Activity
10
+ # class HelloWorld < Temporalio::Activity
11
+ # def execute(name)
12
+ # "Hello, #{name}!"
13
+ # end
14
+ # end
15
+ class Activity
16
+ # Specify a custom name to be used for this activity.
17
+ #
18
+ # By default a full class (with any namespace modules/classes) name will be used.
19
+ #
20
+ # @param new_name [String] Name to be used for this activity
21
+ #
22
+ # @example
23
+ # class Test < Temporalio::Activity
24
+ # activity_name 'custom-activity-name'
25
+ #
26
+ # def execute
27
+ # ...
28
+ # end
29
+ # end
30
+ def self.activity_name(new_name)
31
+ @activity_name = new_name
32
+ end
33
+
34
+ # Mark the activity as shielded from cancellations.
35
+ #
36
+ # Activity cancellations are implemented using the `Thread#raise`, which can unsafely terminate
37
+ # your implementation. To disable this behaviour make sure to mark critical activities as
38
+ # `shielded!`. For shielding a part of your activity consider using
39
+ # {Temporalio::Activity::Context#shield}.
40
+ #
41
+ # @example
42
+ # class Test < Temporalio::Activity
43
+ # shielded!
44
+ #
45
+ # def execute
46
+ # ...
47
+ # end
48
+ # end
49
+ def self.shielded!
50
+ @shielded = true
51
+ end
52
+
53
+ # @api private
54
+ def self._name
55
+ @activity_name || name || ''
56
+ end
57
+
58
+ # @api private
59
+ def self._shielded
60
+ @shielded || false
61
+ end
62
+
63
+ # @api private
64
+ def initialize(context)
65
+ @context = context
66
+ end
67
+
68
+ # This is the main body of your activity's implementation.
69
+ #
70
+ # When implementing this method, you can use as many positional arguments as needed, which will
71
+ # get converted based on the activity invocation in your workflow.
72
+ #
73
+ # Inside of this method you have access to activity's context using the `activity` method. Check
74
+ # out {Temporalio::Activity::Context} for more information on how to use it.
75
+ def execute(*_args)
76
+ raise NoMethodError, 'must implement #execute'
77
+ end
78
+
79
+ private
80
+
81
+ def activity
82
+ @context
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,8 @@
1
+ module Temporalio
2
+ module Bridge
3
+ # @api private
4
+ class Error < StandardError
5
+ class WorkerShutdown < Error; end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ require 'rutie'
2
+ require 'temporalio/bridge/error'
3
+
4
+ # RBS: for some reason __dir__ has a type of (String | nil)
5
+ BRIDGE_DIR = File.expand_path('..', __dir__ || '.')
6
+
7
+ module Temporalio
8
+ # @api private
9
+ module Bridge
10
+ Rutie
11
+ .new(:bridge, lib_path: '', lib_suffix: 'so', lib_prefix: '')
12
+ .init('init_bridge', BRIDGE_DIR)
13
+ end
14
+ end