temporalio 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (628) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -0
  3. data/Cargo.lock +4324 -0
  4. data/Cargo.toml +25 -0
  5. data/Gemfile +20 -0
  6. data/LICENSE +16 -15
  7. data/README.md +985 -183
  8. data/Rakefile +101 -0
  9. data/ext/Cargo.toml +26 -0
  10. data/lib/temporalio/activity/complete_async_error.rb +11 -0
  11. data/lib/temporalio/activity/context.rb +86 -78
  12. data/lib/temporalio/activity/definition.rb +175 -0
  13. data/lib/temporalio/activity/info.rb +44 -47
  14. data/lib/temporalio/activity.rb +8 -81
  15. data/lib/temporalio/api/activity/v1/message.rb +25 -0
  16. data/lib/temporalio/api/batch/v1/message.rb +31 -0
  17. data/lib/temporalio/api/cloud/account/v1/message.rb +28 -0
  18. data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +126 -0
  19. data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +25 -0
  20. data/lib/temporalio/api/cloud/cloudservice.rb +3 -0
  21. data/lib/temporalio/api/cloud/identity/v1/message.rb +41 -0
  22. data/lib/temporalio/api/cloud/namespace/v1/message.rb +42 -0
  23. data/lib/temporalio/api/cloud/nexus/v1/message.rb +31 -0
  24. data/lib/temporalio/api/cloud/operation/v1/message.rb +28 -0
  25. data/lib/temporalio/api/cloud/region/v1/message.rb +24 -0
  26. data/lib/temporalio/api/cloud/resource/v1/message.rb +23 -0
  27. data/lib/temporalio/api/cloud/sink/v1/message.rb +24 -0
  28. data/lib/temporalio/api/cloud/usage/v1/message.rb +31 -0
  29. data/lib/temporalio/api/command/v1/message.rb +46 -0
  30. data/lib/temporalio/api/common/v1/grpc_status.rb +23 -0
  31. data/lib/temporalio/api/common/v1/message.rb +47 -0
  32. data/lib/temporalio/api/enums/v1/batch_operation.rb +22 -0
  33. data/lib/temporalio/api/enums/v1/command_type.rb +21 -0
  34. data/lib/temporalio/api/enums/v1/common.rb +26 -0
  35. data/lib/temporalio/api/enums/v1/event_type.rb +21 -0
  36. data/lib/temporalio/api/enums/v1/failed_cause.rb +26 -0
  37. data/lib/temporalio/api/enums/v1/namespace.rb +23 -0
  38. data/lib/temporalio/api/enums/v1/query.rb +22 -0
  39. data/lib/temporalio/api/enums/v1/reset.rb +23 -0
  40. data/lib/temporalio/api/enums/v1/schedule.rb +21 -0
  41. data/lib/temporalio/api/enums/v1/task_queue.rb +25 -0
  42. data/lib/temporalio/api/enums/v1/update.rb +22 -0
  43. data/lib/temporalio/api/enums/v1/workflow.rb +30 -0
  44. data/lib/temporalio/api/errordetails/v1/message.rb +42 -0
  45. data/lib/temporalio/api/export/v1/message.rb +24 -0
  46. data/lib/temporalio/api/failure/v1/message.rb +35 -0
  47. data/lib/temporalio/api/filter/v1/message.rb +27 -0
  48. data/lib/temporalio/api/history/v1/message.rb +90 -0
  49. data/lib/temporalio/api/namespace/v1/message.rb +31 -0
  50. data/lib/temporalio/api/nexus/v1/message.rb +40 -0
  51. data/lib/temporalio/api/operatorservice/v1/request_response.rb +49 -0
  52. data/lib/temporalio/api/operatorservice/v1/service.rb +23 -0
  53. data/lib/temporalio/api/operatorservice.rb +3 -0
  54. data/lib/temporalio/api/payload_visitor.rb +1513 -0
  55. data/lib/temporalio/api/protocol/v1/message.rb +23 -0
  56. data/lib/temporalio/api/query/v1/message.rb +27 -0
  57. data/lib/temporalio/api/replication/v1/message.rb +26 -0
  58. data/lib/temporalio/api/schedule/v1/message.rb +43 -0
  59. data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +25 -0
  60. data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +21 -0
  61. data/lib/temporalio/api/sdk/v1/user_metadata.rb +23 -0
  62. data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +23 -0
  63. data/lib/temporalio/api/taskqueue/v1/message.rb +45 -0
  64. data/lib/{gen/temporal/api/testservice/v1/request_response_pb.rb → temporalio/api/testservice/v1/request_response.rb} +6 -24
  65. data/lib/temporalio/api/testservice/v1/service.rb +23 -0
  66. data/lib/temporalio/api/update/v1/message.rb +33 -0
  67. data/lib/temporalio/api/version/v1/message.rb +26 -0
  68. data/lib/temporalio/api/workflow/v1/message.rb +43 -0
  69. data/lib/temporalio/api/workflowservice/v1/request_response.rb +204 -0
  70. data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
  71. data/lib/temporalio/api/workflowservice.rb +3 -0
  72. data/lib/temporalio/api.rb +14 -0
  73. data/lib/temporalio/cancellation.rb +170 -0
  74. data/lib/temporalio/client/activity_id_reference.rb +32 -0
  75. data/lib/temporalio/client/async_activity_handle.rb +85 -0
  76. data/lib/temporalio/client/connection/cloud_service.rb +726 -0
  77. data/lib/temporalio/client/connection/operator_service.rb +201 -0
  78. data/lib/temporalio/client/connection/service.rb +42 -0
  79. data/lib/temporalio/client/connection/test_service.rb +111 -0
  80. data/lib/temporalio/client/connection/workflow_service.rb +1041 -0
  81. data/lib/temporalio/client/connection.rb +316 -0
  82. data/lib/temporalio/client/interceptor.rb +416 -0
  83. data/lib/temporalio/client/schedule.rb +967 -0
  84. data/lib/temporalio/client/schedule_handle.rb +126 -0
  85. data/lib/temporalio/client/workflow_execution.rb +100 -0
  86. data/lib/temporalio/client/workflow_execution_count.rb +36 -0
  87. data/lib/temporalio/client/workflow_execution_status.rb +18 -0
  88. data/lib/temporalio/client/workflow_handle.rb +326 -180
  89. data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
  90. data/lib/temporalio/client/workflow_update_handle.rb +65 -0
  91. data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
  92. data/lib/temporalio/client.rb +447 -94
  93. data/lib/temporalio/common_enums.rb +41 -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 +119 -94
  108. data/lib/temporalio/error.rb +155 -0
  109. data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +34 -0
  110. data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +31 -0
  111. data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +33 -0
  112. data/lib/temporalio/internal/bridge/api/common/common.rb +26 -0
  113. data/lib/temporalio/internal/bridge/api/core_interface.rb +40 -0
  114. data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
  115. data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +33 -0
  116. data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +56 -0
  117. data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +57 -0
  118. data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +30 -0
  119. data/lib/temporalio/internal/bridge/api.rb +3 -0
  120. data/lib/temporalio/internal/bridge/client.rb +95 -0
  121. data/lib/temporalio/internal/bridge/runtime.rb +53 -0
  122. data/lib/temporalio/internal/bridge/testing.rb +66 -0
  123. data/lib/temporalio/internal/bridge/worker.rb +85 -0
  124. data/lib/temporalio/internal/bridge.rb +36 -0
  125. data/lib/temporalio/internal/client/implementation.rb +700 -0
  126. data/lib/temporalio/internal/metric.rb +122 -0
  127. data/lib/temporalio/internal/proto_utils.rb +133 -0
  128. data/lib/temporalio/internal/worker/activity_worker.rb +373 -0
  129. data/lib/temporalio/internal/worker/multi_runner.rb +213 -0
  130. data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +54 -0
  131. data/lib/temporalio/internal/worker/workflow_instance/context.rb +329 -0
  132. data/lib/temporalio/internal/worker/workflow_instance/details.rb +44 -0
  133. data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +32 -0
  134. data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +22 -0
  135. data/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb +25 -0
  136. data/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb +41 -0
  137. data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +97 -0
  138. data/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb +62 -0
  139. data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +415 -0
  140. data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +37 -0
  141. data/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb +40 -0
  142. data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +163 -0
  143. data/lib/temporalio/internal/worker/workflow_instance.rb +730 -0
  144. data/lib/temporalio/internal/worker/workflow_worker.rb +196 -0
  145. data/lib/temporalio/internal.rb +7 -0
  146. data/lib/temporalio/metric.rb +109 -0
  147. data/lib/temporalio/retry_policy.rb +55 -73
  148. data/lib/temporalio/runtime.rb +302 -13
  149. data/lib/temporalio/scoped_logger.rb +96 -0
  150. data/lib/temporalio/search_attributes.rb +343 -0
  151. data/lib/temporalio/testing/activity_environment.rb +132 -0
  152. data/lib/temporalio/testing/workflow_environment.rb +345 -74
  153. data/lib/temporalio/testing.rb +4 -169
  154. data/lib/temporalio/version.rb +3 -1
  155. data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
  156. data/lib/temporalio/worker/activity_executor/thread_pool.rb +46 -0
  157. data/lib/temporalio/worker/activity_executor.rb +55 -0
  158. data/lib/temporalio/worker/interceptor.rb +362 -0
  159. data/lib/temporalio/worker/thread_pool.rb +237 -0
  160. data/lib/temporalio/worker/tuner.rb +151 -0
  161. data/lib/temporalio/worker/workflow_executor/thread_pool.rb +230 -0
  162. data/lib/temporalio/worker/workflow_executor.rb +26 -0
  163. data/lib/temporalio/worker.rb +554 -161
  164. data/lib/temporalio/workflow/activity_cancellation_type.rb +20 -0
  165. data/lib/temporalio/workflow/child_workflow_cancellation_type.rb +21 -0
  166. data/lib/temporalio/workflow/child_workflow_handle.rb +43 -0
  167. data/lib/temporalio/workflow/definition.rb +566 -0
  168. data/lib/temporalio/workflow/external_workflow_handle.rb +41 -0
  169. data/lib/temporalio/workflow/future.rb +117 -104
  170. data/lib/temporalio/workflow/handler_unfinished_policy.rb +13 -0
  171. data/lib/temporalio/workflow/info.rb +63 -57
  172. data/lib/temporalio/workflow/parent_close_policy.rb +19 -0
  173. data/lib/temporalio/workflow/update_info.rb +20 -0
  174. data/lib/temporalio/workflow.rb +523 -0
  175. data/lib/temporalio/workflow_history.rb +22 -0
  176. data/lib/temporalio.rb +6 -7
  177. data/temporalio.gemspec +20 -39
  178. metadata +171 -710
  179. data/bridge/Cargo.lock +0 -2997
  180. data/bridge/Cargo.toml +0 -29
  181. data/bridge/sdk-core/ARCHITECTURE.md +0 -76
  182. data/bridge/sdk-core/Cargo.toml +0 -2
  183. data/bridge/sdk-core/LICENSE.txt +0 -23
  184. data/bridge/sdk-core/README.md +0 -117
  185. data/bridge/sdk-core/arch_docs/diagrams/README.md +0 -10
  186. data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +0 -40
  187. data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
  188. data/bridge/sdk-core/arch_docs/sticky_queues.md +0 -51
  189. data/bridge/sdk-core/client/Cargo.toml +0 -40
  190. data/bridge/sdk-core/client/LICENSE.txt +0 -23
  191. data/bridge/sdk-core/client/src/lib.rs +0 -1462
  192. data/bridge/sdk-core/client/src/metrics.rs +0 -174
  193. data/bridge/sdk-core/client/src/raw.rs +0 -932
  194. data/bridge/sdk-core/client/src/retry.rs +0 -763
  195. data/bridge/sdk-core/client/src/workflow_handle/mod.rs +0 -185
  196. data/bridge/sdk-core/core/Cargo.toml +0 -129
  197. data/bridge/sdk-core/core/LICENSE.txt +0 -23
  198. data/bridge/sdk-core/core/benches/workflow_replay.rs +0 -76
  199. data/bridge/sdk-core/core/src/abstractions.rs +0 -355
  200. data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +0 -1049
  201. data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +0 -221
  202. data/bridge/sdk-core/core/src/core_tests/determinism.rs +0 -270
  203. data/bridge/sdk-core/core/src/core_tests/local_activities.rs +0 -1046
  204. data/bridge/sdk-core/core/src/core_tests/mod.rs +0 -100
  205. data/bridge/sdk-core/core/src/core_tests/queries.rs +0 -893
  206. data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +0 -65
  207. data/bridge/sdk-core/core/src/core_tests/workers.rs +0 -257
  208. data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +0 -124
  209. data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +0 -2433
  210. data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +0 -609
  211. data/bridge/sdk-core/core/src/internal_flags.rs +0 -136
  212. data/bridge/sdk-core/core/src/lib.rs +0 -289
  213. data/bridge/sdk-core/core/src/pollers/mod.rs +0 -54
  214. data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +0 -297
  215. data/bridge/sdk-core/core/src/protosext/mod.rs +0 -428
  216. data/bridge/sdk-core/core/src/replay/mod.rs +0 -215
  217. data/bridge/sdk-core/core/src/retry_logic.rs +0 -202
  218. data/bridge/sdk-core/core/src/telemetry/log_export.rs +0 -190
  219. data/bridge/sdk-core/core/src/telemetry/metrics.rs +0 -462
  220. data/bridge/sdk-core/core/src/telemetry/mod.rs +0 -423
  221. data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +0 -83
  222. data/bridge/sdk-core/core/src/test_help/mod.rs +0 -939
  223. data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +0 -536
  224. data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -89
  225. data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +0 -1278
  226. data/bridge/sdk-core/core/src/worker/activities.rs +0 -557
  227. data/bridge/sdk-core/core/src/worker/client/mocks.rs +0 -107
  228. data/bridge/sdk-core/core/src/worker/client.rs +0 -389
  229. data/bridge/sdk-core/core/src/worker/mod.rs +0 -677
  230. data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +0 -35
  231. data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +0 -99
  232. data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +0 -1111
  233. data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +0 -964
  234. data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -294
  235. data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -168
  236. data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +0 -918
  237. data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -137
  238. data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -158
  239. data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -130
  240. data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -1525
  241. data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -324
  242. data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -179
  243. data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -659
  244. data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -439
  245. data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +0 -435
  246. data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +0 -175
  247. data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +0 -249
  248. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +0 -85
  249. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +0 -1280
  250. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +0 -269
  251. data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +0 -213
  252. data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +0 -1305
  253. data/bridge/sdk-core/core/src/worker/workflow/mod.rs +0 -1276
  254. data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +0 -128
  255. data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +0 -125
  256. data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +0 -85
  257. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
  258. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
  259. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +0 -715
  260. data/bridge/sdk-core/core-api/Cargo.toml +0 -33
  261. data/bridge/sdk-core/core-api/LICENSE.txt +0 -23
  262. data/bridge/sdk-core/core-api/src/errors.rs +0 -62
  263. data/bridge/sdk-core/core-api/src/lib.rs +0 -113
  264. data/bridge/sdk-core/core-api/src/telemetry.rs +0 -141
  265. data/bridge/sdk-core/core-api/src/worker.rs +0 -161
  266. data/bridge/sdk-core/etc/deps.svg +0 -162
  267. data/bridge/sdk-core/etc/dynamic-config.yaml +0 -2
  268. data/bridge/sdk-core/etc/otel-collector-config.yaml +0 -36
  269. data/bridge/sdk-core/etc/prometheus.yaml +0 -6
  270. data/bridge/sdk-core/etc/regen-depgraph.sh +0 -5
  271. data/bridge/sdk-core/fsm/Cargo.toml +0 -18
  272. data/bridge/sdk-core/fsm/LICENSE.txt +0 -23
  273. data/bridge/sdk-core/fsm/README.md +0 -3
  274. data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
  275. data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +0 -23
  276. data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +0 -650
  277. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
  278. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +0 -18
  279. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
  280. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +0 -41
  281. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +0 -14
  282. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +0 -11
  283. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +0 -32
  284. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +0 -31
  285. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +0 -46
  286. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +0 -29
  287. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -12
  288. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +0 -32
  289. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +0 -18
  290. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
  291. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +0 -11
  292. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
  293. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +0 -11
  294. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
  295. data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
  296. data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -23
  297. data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +0 -254
  298. data/bridge/sdk-core/fsm/src/lib.rs +0 -2
  299. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
  300. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
  301. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
  302. data/bridge/sdk-core/histories/fail_wf_task.bin +0 -0
  303. data/bridge/sdk-core/histories/timer_workflow_history.bin +0 -0
  304. data/bridge/sdk-core/integ-with-otel.sh +0 -7
  305. data/bridge/sdk-core/protos/api_upstream/README.md +0 -9
  306. data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +0 -40
  307. data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -9
  308. data/bridge/sdk-core/protos/api_upstream/build/go.mod +0 -7
  309. data/bridge/sdk-core/protos/api_upstream/build/go.sum +0 -5
  310. data/bridge/sdk-core/protos/api_upstream/build/tools.go +0 -29
  311. data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +0 -141
  312. data/bridge/sdk-core/protos/api_upstream/go.mod +0 -6
  313. data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -89
  314. data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +0 -248
  315. data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +0 -123
  316. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -47
  317. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -52
  318. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -56
  319. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -170
  320. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -123
  321. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -51
  322. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -50
  323. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -41
  324. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -60
  325. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -59
  326. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -56
  327. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -122
  328. data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -108
  329. data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -114
  330. data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -56
  331. data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +0 -787
  332. data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -99
  333. data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -124
  334. data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -80
  335. data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -57
  336. data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +0 -61
  337. data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -55
  338. data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -379
  339. data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -63
  340. data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -108
  341. data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +0 -111
  342. data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +0 -59
  343. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -146
  344. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +0 -1199
  345. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +0 -415
  346. data/bridge/sdk-core/protos/grpc/health/v1/health.proto +0 -63
  347. data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -79
  348. data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -80
  349. data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -78
  350. data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +0 -16
  351. data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +0 -31
  352. data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -31
  353. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +0 -270
  354. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -305
  355. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -35
  356. data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +0 -38
  357. data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +0 -13
  358. data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +0 -141
  359. data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -63
  360. data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -90
  361. data/bridge/sdk-core/rustfmt.toml +0 -1
  362. data/bridge/sdk-core/sdk/Cargo.toml +0 -48
  363. data/bridge/sdk-core/sdk/LICENSE.txt +0 -23
  364. data/bridge/sdk-core/sdk/src/activity_context.rs +0 -230
  365. data/bridge/sdk-core/sdk/src/app_data.rs +0 -37
  366. data/bridge/sdk-core/sdk/src/interceptors.rs +0 -50
  367. data/bridge/sdk-core/sdk/src/lib.rs +0 -861
  368. data/bridge/sdk-core/sdk/src/payload_converter.rs +0 -11
  369. data/bridge/sdk-core/sdk/src/workflow_context/options.rs +0 -295
  370. data/bridge/sdk-core/sdk/src/workflow_context.rs +0 -694
  371. data/bridge/sdk-core/sdk/src/workflow_future.rs +0 -500
  372. data/bridge/sdk-core/sdk-core-protos/Cargo.toml +0 -33
  373. data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +0 -23
  374. data/bridge/sdk-core/sdk-core-protos/build.rs +0 -142
  375. data/bridge/sdk-core/sdk-core-protos/src/constants.rs +0 -7
  376. data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +0 -557
  377. data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +0 -234
  378. data/bridge/sdk-core/sdk-core-protos/src/lib.rs +0 -2088
  379. data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +0 -48
  380. data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +0 -14
  381. data/bridge/sdk-core/test-utils/Cargo.toml +0 -38
  382. data/bridge/sdk-core/test-utils/src/canned_histories.rs +0 -1389
  383. data/bridge/sdk-core/test-utils/src/histfetch.rs +0 -28
  384. data/bridge/sdk-core/test-utils/src/lib.rs +0 -709
  385. data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
  386. data/bridge/sdk-core/test-utils/src/workflows.rs +0 -29
  387. data/bridge/sdk-core/tests/fuzzy_workflow.rs +0 -130
  388. data/bridge/sdk-core/tests/heavy_tests.rs +0 -265
  389. data/bridge/sdk-core/tests/integ_tests/client_tests.rs +0 -36
  390. data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +0 -150
  391. data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +0 -223
  392. data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +0 -239
  393. data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -90
  394. data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +0 -314
  395. data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +0 -151
  396. data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +0 -902
  397. data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
  398. data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -60
  399. data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -51
  400. data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -51
  401. data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -64
  402. data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -47
  403. data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -669
  404. data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -54
  405. data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -92
  406. data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +0 -228
  407. data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +0 -94
  408. data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -171
  409. data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +0 -85
  410. data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -120
  411. data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +0 -77
  412. data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +0 -596
  413. data/bridge/sdk-core/tests/main.rs +0 -103
  414. data/bridge/sdk-core/tests/runner.rs +0 -132
  415. data/bridge/sdk-core/tests/wf_input_replay.rs +0 -32
  416. data/bridge/src/connection.rs +0 -202
  417. data/bridge/src/lib.rs +0 -494
  418. data/bridge/src/runtime.rs +0 -54
  419. data/bridge/src/test_server.rs +0 -153
  420. data/bridge/src/worker.rs +0 -197
  421. data/ext/Rakefile +0 -9
  422. data/lib/gen/dependencies/gogoproto/gogo_pb.rb +0 -14
  423. data/lib/gen/temporal/api/batch/v1/message_pb.rb +0 -50
  424. data/lib/gen/temporal/api/command/v1/message_pb.rb +0 -160
  425. data/lib/gen/temporal/api/common/v1/message_pb.rb +0 -73
  426. data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +0 -33
  427. data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +0 -37
  428. data/lib/gen/temporal/api/enums/v1/common_pb.rb +0 -42
  429. data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +0 -68
  430. data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +0 -79
  431. data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +0 -37
  432. data/lib/gen/temporal/api/enums/v1/query_pb.rb +0 -31
  433. data/lib/gen/temporal/api/enums/v1/reset_pb.rb +0 -24
  434. data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +0 -28
  435. data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +0 -30
  436. data/lib/gen/temporal/api/enums/v1/update_pb.rb +0 -25
  437. data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +0 -89
  438. data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +0 -84
  439. data/lib/gen/temporal/api/failure/v1/message_pb.rb +0 -83
  440. data/lib/gen/temporal/api/filter/v1/message_pb.rb +0 -40
  441. data/lib/gen/temporal/api/history/v1/message_pb.rb +0 -498
  442. data/lib/gen/temporal/api/namespace/v1/message_pb.rb +0 -64
  443. data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +0 -88
  444. data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +0 -20
  445. data/lib/gen/temporal/api/protocol/v1/message_pb.rb +0 -30
  446. data/lib/gen/temporal/api/query/v1/message_pb.rb +0 -38
  447. data/lib/gen/temporal/api/replication/v1/message_pb.rb +0 -37
  448. data/lib/gen/temporal/api/schedule/v1/message_pb.rb +0 -149
  449. data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +0 -23
  450. data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +0 -73
  451. data/lib/gen/temporal/api/testservice/v1/service_pb.rb +0 -21
  452. data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -72
  453. data/lib/gen/temporal/api/version/v1/message_pb.rb +0 -41
  454. data/lib/gen/temporal/api/workflow/v1/message_pb.rb +0 -111
  455. data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +0 -798
  456. data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +0 -20
  457. data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +0 -62
  458. data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +0 -61
  459. data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +0 -61
  460. data/lib/gen/temporal/sdk/core/common/common_pb.rb +0 -26
  461. data/lib/gen/temporal/sdk/core/core_interface_pb.rb +0 -40
  462. data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +0 -31
  463. data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +0 -171
  464. data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +0 -200
  465. data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +0 -41
  466. data/lib/temporalio/bridge/connect_options.rb +0 -15
  467. data/lib/temporalio/bridge/error.rb +0 -8
  468. data/lib/temporalio/bridge/retry_config.rb +0 -24
  469. data/lib/temporalio/bridge/tls_options.rb +0 -19
  470. data/lib/temporalio/bridge.rb +0 -14
  471. data/lib/temporalio/client/implementation.rb +0 -340
  472. data/lib/temporalio/connection/retry_config.rb +0 -44
  473. data/lib/temporalio/connection/service.rb +0 -20
  474. data/lib/temporalio/connection/test_service.rb +0 -92
  475. data/lib/temporalio/connection/tls_options.rb +0 -51
  476. data/lib/temporalio/connection/workflow_service.rb +0 -731
  477. data/lib/temporalio/connection.rb +0 -86
  478. data/lib/temporalio/data_converter.rb +0 -191
  479. data/lib/temporalio/error/workflow_failure.rb +0 -19
  480. data/lib/temporalio/errors.rb +0 -40
  481. data/lib/temporalio/failure_converter/base.rb +0 -26
  482. data/lib/temporalio/failure_converter/basic.rb +0 -319
  483. data/lib/temporalio/failure_converter.rb +0 -7
  484. data/lib/temporalio/interceptor/activity_inbound.rb +0 -22
  485. data/lib/temporalio/interceptor/activity_outbound.rb +0 -24
  486. data/lib/temporalio/interceptor/chain.rb +0 -28
  487. data/lib/temporalio/interceptor/client.rb +0 -127
  488. data/lib/temporalio/interceptor.rb +0 -22
  489. data/lib/temporalio/payload_codec/base.rb +0 -32
  490. data/lib/temporalio/payload_converter/base.rb +0 -24
  491. data/lib/temporalio/payload_converter/bytes.rb +0 -27
  492. data/lib/temporalio/payload_converter/composite.rb +0 -49
  493. data/lib/temporalio/payload_converter/encoding_base.rb +0 -35
  494. data/lib/temporalio/payload_converter/json.rb +0 -26
  495. data/lib/temporalio/payload_converter/nil.rb +0 -26
  496. data/lib/temporalio/payload_converter.rb +0 -14
  497. data/lib/temporalio/retry_state.rb +0 -35
  498. data/lib/temporalio/testing/time_skipping_handle.rb +0 -32
  499. data/lib/temporalio/testing/time_skipping_interceptor.rb +0 -23
  500. data/lib/temporalio/timeout_type.rb +0 -29
  501. data/lib/temporalio/worker/activity_runner.rb +0 -114
  502. data/lib/temporalio/worker/activity_worker.rb +0 -164
  503. data/lib/temporalio/worker/reactor.rb +0 -46
  504. data/lib/temporalio/worker/runner.rb +0 -63
  505. data/lib/temporalio/worker/sync_worker.rb +0 -124
  506. data/lib/temporalio/worker/thread_pool_executor.rb +0 -51
  507. data/lib/temporalio/workflow/async.rb +0 -46
  508. data/lib/temporalio/workflow/execution_info.rb +0 -54
  509. data/lib/temporalio/workflow/execution_status.rb +0 -36
  510. data/lib/temporalio/workflow/id_reuse_policy.rb +0 -36
  511. data/lib/temporalio/workflow/query_reject_condition.rb +0 -33
  512. data/lib/thermite_patch.rb +0 -33
  513. data/sig/async.rbs +0 -17
  514. data/sig/protobuf.rbs +0 -16
  515. data/sig/protos/dependencies/gogoproto/gogo.rbs +0 -914
  516. data/sig/protos/google/protobuf/any.rbs +0 -157
  517. data/sig/protos/google/protobuf/descriptor.rbs +0 -2825
  518. data/sig/protos/google/protobuf/duration.rbs +0 -114
  519. data/sig/protos/google/protobuf/empty.rbs +0 -36
  520. data/sig/protos/google/protobuf/timestamp.rbs +0 -145
  521. data/sig/protos/google/protobuf/wrappers.rbs +0 -358
  522. data/sig/protos/temporal/api/batch/v1/message.rbs +0 -300
  523. data/sig/protos/temporal/api/command/v1/message.rbs +0 -1399
  524. data/sig/protos/temporal/api/common/v1/message.rbs +0 -528
  525. data/sig/protos/temporal/api/enums/v1/batch_operation.rbs +0 -79
  526. data/sig/protos/temporal/api/enums/v1/command_type.rbs +0 -68
  527. data/sig/protos/temporal/api/enums/v1/common.rbs +0 -118
  528. data/sig/protos/temporal/api/enums/v1/event_type.rbs +0 -264
  529. data/sig/protos/temporal/api/enums/v1/failed_cause.rbs +0 -277
  530. data/sig/protos/temporal/api/enums/v1/namespace.rbs +0 -108
  531. data/sig/protos/temporal/api/enums/v1/query.rbs +0 -81
  532. data/sig/protos/temporal/api/enums/v1/reset.rbs +0 -44
  533. data/sig/protos/temporal/api/enums/v1/schedule.rbs +0 -72
  534. data/sig/protos/temporal/api/enums/v1/task_queue.rbs +0 -92
  535. data/sig/protos/temporal/api/enums/v1/update.rbs +0 -64
  536. data/sig/protos/temporal/api/enums/v1/workflow.rbs +0 -371
  537. data/sig/protos/temporal/api/errordetails/v1/message.rbs +0 -551
  538. data/sig/protos/temporal/api/failure/v1/message.rbs +0 -581
  539. data/sig/protos/temporal/api/filter/v1/message.rbs +0 -171
  540. data/sig/protos/temporal/api/history/v1/message.rbs +0 -4609
  541. data/sig/protos/temporal/api/namespace/v1/message.rbs +0 -410
  542. data/sig/protos/temporal/api/operatorservice/v1/request_response.rbs +0 -643
  543. data/sig/protos/temporal/api/operatorservice/v1/service.rbs +0 -17
  544. data/sig/protos/temporal/api/protocol/v1/message.rbs +0 -84
  545. data/sig/protos/temporal/api/query/v1/message.rbs +0 -182
  546. data/sig/protos/temporal/api/replication/v1/message.rbs +0 -148
  547. data/sig/protos/temporal/api/schedule/v1/message.rbs +0 -1488
  548. data/sig/protos/temporal/api/sdk/v1/task_complete_metadata.rbs +0 -110
  549. data/sig/protos/temporal/api/taskqueue/v1/message.rbs +0 -486
  550. data/sig/protos/temporal/api/testservice/v1/request_response.rbs +0 -249
  551. data/sig/protos/temporal/api/testservice/v1/service.rbs +0 -15
  552. data/sig/protos/temporal/api/update/v1/message.rbs +0 -489
  553. data/sig/protos/temporal/api/version/v1/message.rbs +0 -184
  554. data/sig/protos/temporal/api/workflow/v1/message.rbs +0 -824
  555. data/sig/protos/temporal/api/workflowservice/v1/request_response.rbs +0 -7250
  556. data/sig/protos/temporal/api/workflowservice/v1/service.rbs +0 -22
  557. data/sig/protos/temporal/sdk/core/activity_result/activity_result.rbs +0 -380
  558. data/sig/protos/temporal/sdk/core/activity_task/activity_task.rbs +0 -386
  559. data/sig/protos/temporal/sdk/core/child_workflow/child_workflow.rbs +0 -323
  560. data/sig/protos/temporal/sdk/core/common/common.rbs +0 -62
  561. data/sig/protos/temporal/sdk/core/core_interface.rbs +0 -101
  562. data/sig/protos/temporal/sdk/core/external_data/external_data.rbs +0 -119
  563. data/sig/protos/temporal/sdk/core/workflow_activation/workflow_activation.rbs +0 -1473
  564. data/sig/protos/temporal/sdk/core/workflow_commands/workflow_commands.rbs +0 -1784
  565. data/sig/protos/temporal/sdk/core/workflow_completion/workflow_completion.rbs +0 -180
  566. data/sig/ruby.rbs +0 -12
  567. data/sig/temporalio/activity/context.rbs +0 -29
  568. data/sig/temporalio/activity/info.rbs +0 -43
  569. data/sig/temporalio/activity.rbs +0 -19
  570. data/sig/temporalio/bridge/connect_options.rbs +0 -19
  571. data/sig/temporalio/bridge/error.rbs +0 -8
  572. data/sig/temporalio/bridge/retry_config.rbs +0 -21
  573. data/sig/temporalio/bridge/tls_options.rbs +0 -17
  574. data/sig/temporalio/bridge.rbs +0 -71
  575. data/sig/temporalio/client/implementation.rbs +0 -38
  576. data/sig/temporalio/client/workflow_handle.rbs +0 -41
  577. data/sig/temporalio/client.rbs +0 -35
  578. data/sig/temporalio/connection/retry_config.rbs +0 -37
  579. data/sig/temporalio/connection/service.rbs +0 -14
  580. data/sig/temporalio/connection/test_service.rbs +0 -13
  581. data/sig/temporalio/connection/tls_options.rbs +0 -43
  582. data/sig/temporalio/connection/workflow_service.rbs +0 -48
  583. data/sig/temporalio/connection.rbs +0 -30
  584. data/sig/temporalio/data_converter.rbs +0 -35
  585. data/sig/temporalio/error/failure.rbs +0 -121
  586. data/sig/temporalio/error/workflow_failure.rbs +0 -9
  587. data/sig/temporalio/errors.rbs +0 -36
  588. data/sig/temporalio/failure_converter/base.rbs +0 -12
  589. data/sig/temporalio/failure_converter/basic.rbs +0 -86
  590. data/sig/temporalio/failure_converter.rbs +0 -5
  591. data/sig/temporalio/interceptor/activity_inbound.rbs +0 -21
  592. data/sig/temporalio/interceptor/activity_outbound.rbs +0 -10
  593. data/sig/temporalio/interceptor/chain.rbs +0 -24
  594. data/sig/temporalio/interceptor/client.rbs +0 -148
  595. data/sig/temporalio/interceptor.rbs +0 -6
  596. data/sig/temporalio/payload_codec/base.rbs +0 -12
  597. data/sig/temporalio/payload_converter/base.rbs +0 -12
  598. data/sig/temporalio/payload_converter/bytes.rbs +0 -9
  599. data/sig/temporalio/payload_converter/composite.rbs +0 -19
  600. data/sig/temporalio/payload_converter/encoding_base.rbs +0 -14
  601. data/sig/temporalio/payload_converter/json.rbs +0 -9
  602. data/sig/temporalio/payload_converter/nil.rbs +0 -9
  603. data/sig/temporalio/payload_converter.rbs +0 -5
  604. data/sig/temporalio/retry_policy.rbs +0 -25
  605. data/sig/temporalio/retry_state.rbs +0 -20
  606. data/sig/temporalio/runtime.rbs +0 -12
  607. data/sig/temporalio/testing/time_skipping_handle.rbs +0 -15
  608. data/sig/temporalio/testing/time_skipping_interceptor.rbs +0 -13
  609. data/sig/temporalio/testing/workflow_environment.rbs +0 -22
  610. data/sig/temporalio/testing.rbs +0 -35
  611. data/sig/temporalio/timeout_type.rbs +0 -15
  612. data/sig/temporalio/version.rbs +0 -3
  613. data/sig/temporalio/worker/activity_runner.rbs +0 -35
  614. data/sig/temporalio/worker/activity_worker.rbs +0 -44
  615. data/sig/temporalio/worker/reactor.rbs +0 -22
  616. data/sig/temporalio/worker/runner.rbs +0 -21
  617. data/sig/temporalio/worker/sync_worker.rbs +0 -23
  618. data/sig/temporalio/worker/thread_pool_executor.rbs +0 -23
  619. data/sig/temporalio/worker.rbs +0 -46
  620. data/sig/temporalio/workflow/async.rbs +0 -9
  621. data/sig/temporalio/workflow/execution_info.rbs +0 -55
  622. data/sig/temporalio/workflow/execution_status.rbs +0 -21
  623. data/sig/temporalio/workflow/future.rbs +0 -40
  624. data/sig/temporalio/workflow/id_reuse_policy.rbs +0 -15
  625. data/sig/temporalio/workflow/info.rbs +0 -55
  626. data/sig/temporalio/workflow/query_reject_condition.rbs +0 -14
  627. data/sig/temporalio.rbs +0 -2
  628. data/sig/thermite_patch.rbs +0 -15
@@ -1,1525 +0,0 @@
1
- use super::{
2
- workflow_machines::MachineResponse, Cancellable, EventInfo, OnEventWrapper, WFMachinesAdapter,
3
- WFMachinesError,
4
- };
5
- use crate::{
6
- internal_flags::CoreInternalFlags,
7
- protosext::{CompleteLocalActivityData, HistoryEventExt, ValidScheduleLA},
8
- worker::{
9
- workflow::{machines::HistEventData, InternalFlagsRef, OutgoingJob},
10
- LocalActivityExecutionResult,
11
- },
12
- };
13
- use rustfsm::{fsm, MachineError, StateMachine, TransitionResult};
14
- use std::{
15
- convert::TryFrom,
16
- time::{Duration, SystemTime},
17
- };
18
- use temporal_sdk_core_protos::{
19
- constants::LOCAL_ACTIVITY_MARKER_NAME,
20
- coresdk::{
21
- activity_result::{
22
- ActivityResolution, Cancellation, DoBackoff, Failure as ActFail, Success,
23
- },
24
- common::build_local_activity_marker_details,
25
- external_data::LocalActivityMarkerData,
26
- workflow_activation::ResolveActivity,
27
- workflow_commands::ActivityCancellationType,
28
- },
29
- temporal::api::{
30
- command::v1::{Command, RecordMarkerCommandAttributes},
31
- enums::v1::{CommandType, EventType},
32
- failure::v1::failure::FailureInfo,
33
- history::v1::HistoryEvent,
34
- },
35
- utilities::TryIntoOrNone,
36
- };
37
-
38
- fsm! {
39
- pub(super) name LocalActivityMachine;
40
- command LocalActivityCommand;
41
- error WFMachinesError;
42
- shared_state SharedState;
43
-
44
- // Machine is created in either executing or replaying (referring to whether or not the workflow
45
- // is replaying), and then immediately scheduled and transitions to either requesting that lang
46
- // execute the activity, or waiting for the marker from history.
47
- Executing --(Schedule, shared on_schedule) --> RequestSent;
48
- Replaying --(Schedule, on_schedule) --> WaitingMarkerEvent;
49
- ReplayingPreResolved --(Schedule, on_schedule) --> WaitingMarkerEventPreResolved;
50
-
51
- // Execution path =============================================================================
52
- RequestSent --(HandleResult(ResolveDat), on_handle_result) --> MarkerCommandCreated;
53
- // We loop back on RequestSent here because the LA needs to report its result
54
- RequestSent --(Cancel, on_cancel_requested) --> RequestSent;
55
- // No wait cancels skip waiting for the LA to report the result, but do generate a command
56
- // to record the cancel marker
57
- RequestSent --(NoWaitCancel(ActivityCancellationType), shared on_no_wait_cancel)
58
- --> MarkerCommandCreated;
59
-
60
- MarkerCommandCreated --(CommandRecordMarker, on_command_record_marker) --> ResultNotified;
61
-
62
- ResultNotified --(MarkerRecorded(CompleteLocalActivityData), shared on_marker_recorded)
63
- --> MarkerCommandRecorded;
64
-
65
- // Replay path ================================================================================
66
- // LAs on the replay path always need to eventually see the marker
67
- WaitingMarkerEvent --(MarkerRecorded(CompleteLocalActivityData), shared on_marker_recorded)
68
- --> MarkerCommandRecorded;
69
- // If we are told to cancel while waiting for the marker, we still need to wait for the marker.
70
- WaitingMarkerEvent --(Cancel, on_cancel_requested) --> WaitingMarkerEvent;
71
- // Because there could be non-heartbeat WFTs (ex: signals being received) between scheduling
72
- // the LA and the marker being recorded, peekahead might not always resolve the LA *before*
73
- // scheduling it. This transition accounts for that.
74
- WaitingMarkerEvent --(HandleKnownResult(ResolveDat), on_handle_result) --> WaitingMarkerEvent;
75
- WaitingMarkerEvent --(NoWaitCancel(ActivityCancellationType),
76
- on_no_wait_cancel) --> WaitingMarkerEvent;
77
-
78
- // It is entirely possible to have started the LA while replaying, only to find that we have
79
- // reached a new WFT and there still was no marker. In such cases we need to execute the LA.
80
- // This can easily happen if upon first execution, the worker does WFT heartbeating but then
81
- // dies for some reason.
82
- WaitingMarkerEvent --(StartedNonReplayWFT, shared on_started_non_replay_wft) --> RequestSent;
83
-
84
- // If the activity is pre resolved we still expect to see marker recorded event at some point,
85
- // even though we already resolved the activity.
86
- WaitingMarkerEventPreResolved --(MarkerRecorded(CompleteLocalActivityData),
87
- shared on_marker_recorded) --> MarkerCommandRecorded;
88
- // Ignore cancellations when waiting for the marker after being pre-resolved
89
- WaitingMarkerEventPreResolved --(Cancel) --> WaitingMarkerEventPreResolved;
90
- WaitingMarkerEventPreResolved --(NoWaitCancel(ActivityCancellationType))
91
- --> WaitingMarkerEventPreResolved;
92
-
93
- // Ignore cancellation in final state
94
- MarkerCommandRecorded --(Cancel, on_cancel_requested) --> MarkerCommandRecorded;
95
- MarkerCommandRecorded --(NoWaitCancel(ActivityCancellationType),
96
- on_no_wait_cancel) --> MarkerCommandRecorded;
97
-
98
- // LAs reporting status after they've handled their result can simply be ignored. We could
99
- // optimize this away higher up but that feels very overkill.
100
- MarkerCommandCreated --(HandleResult(ResolveDat)) --> MarkerCommandCreated;
101
- ResultNotified --(HandleResult(ResolveDat)) --> ResultNotified;
102
- MarkerCommandRecorded --(HandleResult(ResolveDat)) --> MarkerCommandRecorded;
103
- }
104
-
105
- #[derive(Debug, Clone)]
106
- pub(super) struct ResolveDat {
107
- pub(super) result: LocalActivityExecutionResult,
108
- pub(super) complete_time: Option<SystemTime>,
109
- pub(super) attempt: u32,
110
- pub(super) backoff: Option<prost_types::Duration>,
111
- pub(super) original_schedule_time: Option<SystemTime>,
112
- }
113
-
114
- impl From<CompleteLocalActivityData> for ResolveDat {
115
- fn from(d: CompleteLocalActivityData) -> Self {
116
- ResolveDat {
117
- result: match d.result {
118
- Ok(res) => LocalActivityExecutionResult::Completed(Success { result: Some(res) }),
119
- Err(fail) => {
120
- if matches!(fail.failure_info, Some(FailureInfo::CanceledFailureInfo(_))) {
121
- LocalActivityExecutionResult::Cancelled(Cancellation {
122
- failure: Some(fail),
123
- })
124
- } else {
125
- LocalActivityExecutionResult::Failed(ActFail {
126
- failure: Some(fail),
127
- })
128
- }
129
- }
130
- },
131
- complete_time: d.marker_dat.complete_time.try_into_or_none(),
132
- attempt: d.marker_dat.attempt,
133
- backoff: d.marker_dat.backoff,
134
- original_schedule_time: d.marker_dat.original_schedule_time.try_into_or_none(),
135
- }
136
- }
137
- }
138
-
139
- /// Creates a new local activity state machine & immediately schedules the local activity for
140
- /// execution. No command is produced immediately to be sent to the server, as the local activity
141
- /// must resolve before we send a record marker command. A [MachineResponse] may be produced,
142
- /// to queue the LA for execution if it needs to be.
143
- pub(super) fn new_local_activity(
144
- mut attrs: ValidScheduleLA,
145
- replaying_when_invoked: bool,
146
- maybe_pre_resolved: Option<ResolveDat>,
147
- wf_time: Option<SystemTime>,
148
- internal_flags: InternalFlagsRef,
149
- ) -> Result<(LocalActivityMachine, Vec<MachineResponse>), WFMachinesError> {
150
- let initial_state = if replaying_when_invoked {
151
- if let Some(dat) = maybe_pre_resolved {
152
- ReplayingPreResolved { dat }.into()
153
- } else {
154
- Replaying {}.into()
155
- }
156
- } else {
157
- if maybe_pre_resolved.is_some() {
158
- return Err(WFMachinesError::Nondeterminism(
159
- "Local activity cannot be created as pre-resolved while not replaying".to_string(),
160
- ));
161
- }
162
- Executing {}.into()
163
- };
164
-
165
- // If the scheduled LA doesn't already have an "original" schedule time, assign one.
166
- attrs
167
- .original_schedule_time
168
- .get_or_insert(SystemTime::now());
169
-
170
- let mut machine = LocalActivityMachine {
171
- state: initial_state,
172
- shared_state: SharedState {
173
- attrs,
174
- replaying_when_invoked,
175
- wf_time_when_started: wf_time,
176
- internal_flags,
177
- },
178
- };
179
-
180
- let mut res = OnEventWrapper::on_event_mut(&mut machine, LocalActivityMachineEvents::Schedule)
181
- .expect("Scheduling local activities doesn't fail");
182
- let mr = if let Some(res) = res.pop() {
183
- machine
184
- .adapt_response(res, None)
185
- .expect("Adapting LA schedule response doesn't fail")
186
- } else {
187
- vec![]
188
- };
189
- Ok((machine, mr))
190
- }
191
-
192
- impl LocalActivityMachine {
193
- /// Is called to check if, while handling the LA marker event, we should avoid doing normal
194
- /// command-event processing - instead simply applying the event to this machine and then
195
- /// skipping over the rest. If this machine is in the `ResultNotified` state, that means
196
- /// command handling should proceed as normal (ie: The command needs to be matched and removed).
197
- /// The other valid states to make this check in are the `WaitingMarkerEvent[PreResolved]`
198
- /// states, which will return true.
199
- ///
200
- /// Attempting the check in any other state likely means a bug in the SDK.
201
- pub(super) fn marker_should_get_special_handling(&self) -> Result<bool, WFMachinesError> {
202
- match &self.state {
203
- LocalActivityMachineState::ResultNotified(_) => Ok(false),
204
- LocalActivityMachineState::WaitingMarkerEvent(_) => Ok(true),
205
- LocalActivityMachineState::WaitingMarkerEventPreResolved(_) => Ok(true),
206
- _ => Err(WFMachinesError::Fatal(format!(
207
- "Attempted to check for LA marker handling in invalid state {}",
208
- self.state
209
- ))),
210
- }
211
- }
212
-
213
- /// Returns true if the machine will willingly accept data from a marker in its current state.
214
- /// IE: Calling [Self::try_resolve_with_dat] makes sense.
215
- pub(super) fn will_accept_resolve_marker(&self) -> bool {
216
- matches!(self.state, LocalActivityMachineState::WaitingMarkerEvent(_))
217
- }
218
-
219
- /// Must be called if the workflow encounters a non-replay workflow task
220
- pub(super) fn encountered_non_replay_wft(
221
- &mut self,
222
- ) -> Result<Vec<MachineResponse>, WFMachinesError> {
223
- // This only applies to the waiting-for-marker state. It can safely be ignored in the others
224
- if !matches!(
225
- self.state(),
226
- LocalActivityMachineState::WaitingMarkerEvent(_)
227
- ) {
228
- return Ok(vec![]);
229
- }
230
-
231
- let mut res =
232
- OnEventWrapper::on_event_mut(self, LocalActivityMachineEvents::StartedNonReplayWFT)
233
- .map_err(|e| match e {
234
- MachineError::InvalidTransition => WFMachinesError::Fatal(format!(
235
- "Invalid transition while notifying local activity (seq {})\
236
- of non-replay-wft-started in {}",
237
- self.shared_state.attrs.seq,
238
- self.state(),
239
- )),
240
- MachineError::Underlying(e) => e,
241
- })?;
242
- let res = res.pop().expect("Always produces one response");
243
- Ok(self
244
- .adapt_response(res, None)
245
- .expect("Adapting LA wft-non-replay response doesn't fail"))
246
- }
247
-
248
- /// Attempt to resolve the local activity with a result from execution (not from history)
249
- pub(super) fn try_resolve(
250
- &mut self,
251
- result: LocalActivityExecutionResult,
252
- runtime: Duration,
253
- attempt: u32,
254
- backoff: Option<prost_types::Duration>,
255
- original_schedule_time: Option<SystemTime>,
256
- ) -> Result<Vec<MachineResponse>, WFMachinesError> {
257
- self._try_resolve(
258
- ResolveDat {
259
- result,
260
- complete_time: self.shared_state.wf_time_when_started.map(|t| t + runtime),
261
- attempt,
262
- backoff,
263
- original_schedule_time,
264
- },
265
- false,
266
- )
267
- }
268
-
269
- /// Attempt to resolve the local activity with already known data, ex pre-resolved data
270
- pub(super) fn try_resolve_with_dat(
271
- &mut self,
272
- dat: ResolveDat,
273
- ) -> Result<Vec<MachineResponse>, WFMachinesError> {
274
- self._try_resolve(dat, true)
275
- }
276
-
277
- fn _try_resolve(
278
- &mut self,
279
- dat: ResolveDat,
280
- from_marker: bool,
281
- ) -> Result<Vec<MachineResponse>, WFMachinesError> {
282
- let evt = if from_marker {
283
- LocalActivityMachineEvents::HandleKnownResult(dat)
284
- } else {
285
- LocalActivityMachineEvents::HandleResult(dat)
286
- };
287
- let res = OnEventWrapper::on_event_mut(self, evt).map_err(|e| match e {
288
- MachineError::InvalidTransition => WFMachinesError::Fatal(format!(
289
- "Invalid transition resolving local activity (seq {}, from marker: {}) in {}",
290
- self.shared_state.attrs.seq,
291
- from_marker,
292
- self.state(),
293
- )),
294
- MachineError::Underlying(e) => e,
295
- })?;
296
-
297
- Ok(res
298
- .into_iter()
299
- .flat_map(|res| {
300
- self.adapt_response(res, None)
301
- .expect("Adapting LA resolve response doesn't fail")
302
- })
303
- .collect())
304
- }
305
- }
306
-
307
- #[derive(Clone)]
308
- pub(super) struct SharedState {
309
- attrs: ValidScheduleLA,
310
- replaying_when_invoked: bool,
311
- wf_time_when_started: Option<SystemTime>,
312
- internal_flags: InternalFlagsRef,
313
- }
314
-
315
- impl SharedState {
316
- fn produce_no_wait_cancel_resolve_dat(&self) -> ResolveDat {
317
- ResolveDat {
318
- result: LocalActivityExecutionResult::empty_cancel(),
319
- // Just don't provide a complete time, which means try-cancel/abandon cancels won't
320
- // advance the clock. Seems like that's fine, since you can only cancel after awaiting
321
- // some other command, which would have appropriately advanced the clock anyway.
322
- complete_time: None,
323
- attempt: self.attrs.attempt,
324
- backoff: None,
325
- original_schedule_time: self.attrs.original_schedule_time,
326
- }
327
- }
328
- }
329
-
330
- #[allow(clippy::large_enum_variant)]
331
- #[derive(Debug, derive_more::Display)]
332
- pub(super) enum LocalActivityCommand {
333
- RequestActivityExecution(ValidScheduleLA),
334
- #[display(fmt = "Resolved")]
335
- Resolved(ResolveDat),
336
- /// The fake marker is used to avoid special casing marker recorded event handling.
337
- /// If we didn't have the fake marker, there would be no "outgoing command" to match
338
- /// against the event. This way there is, but the command never will be issued to
339
- /// server because it is understood to be meaningless.
340
- #[display(fmt = "FakeMarker")]
341
- FakeMarker,
342
- /// Indicate we want to cancel an LA that is currently executing, or look up if we have
343
- /// processed a marker with resolution data since the machine was constructed.
344
- #[display(fmt = "Cancel")]
345
- RequestCancel,
346
- }
347
-
348
- #[derive(Default, Clone)]
349
- pub(super) struct Executing {}
350
-
351
- impl Executing {
352
- pub(super) fn on_schedule(
353
- self,
354
- dat: SharedState,
355
- ) -> LocalActivityMachineTransition<RequestSent> {
356
- TransitionResult::commands([LocalActivityCommand::RequestActivityExecution(dat.attrs)])
357
- }
358
- }
359
-
360
- #[derive(Clone, Copy, PartialEq, Eq)]
361
- enum ResultType {
362
- Completed,
363
- Cancelled,
364
- Failed,
365
- }
366
- #[derive(Clone)]
367
- pub(super) struct MarkerCommandCreated {
368
- result_type: ResultType,
369
- }
370
- impl From<MarkerCommandCreated> for ResultNotified {
371
- fn from(mc: MarkerCommandCreated) -> Self {
372
- Self {
373
- result_type: mc.result_type,
374
- }
375
- }
376
- }
377
-
378
- impl MarkerCommandCreated {
379
- pub(super) fn on_command_record_marker(self) -> LocalActivityMachineTransition<ResultNotified> {
380
- TransitionResult::from(self)
381
- }
382
- }
383
-
384
- #[derive(Default, Clone)]
385
- pub(super) struct MarkerCommandRecorded {}
386
- impl MarkerCommandRecorded {
387
- fn on_cancel_requested(self) -> LocalActivityMachineTransition<MarkerCommandRecorded> {
388
- // We still must issue a cancel request even if this command is resolved, because if it
389
- // failed and we are backing off locally, we must tell the LA dispatcher to quit retrying.
390
- TransitionResult::ok([LocalActivityCommand::RequestCancel], self)
391
- }
392
-
393
- fn on_no_wait_cancel(
394
- self,
395
- cancel_type: ActivityCancellationType,
396
- ) -> LocalActivityMachineTransition<MarkerCommandRecorded> {
397
- if matches!(cancel_type, ActivityCancellationType::TryCancel) {
398
- // We still must issue a cancel request even if this command is resolved, because if it
399
- // failed and we are backing off locally, we must tell the LA dispatcher to quit
400
- // retrying.
401
- TransitionResult::ok(
402
- [LocalActivityCommand::RequestCancel],
403
- MarkerCommandRecorded::default(),
404
- )
405
- } else {
406
- TransitionResult::default()
407
- }
408
- }
409
- }
410
-
411
- #[derive(Default, Clone)]
412
- pub(super) struct Replaying {}
413
- impl Replaying {
414
- pub(super) fn on_schedule(self) -> LocalActivityMachineTransition<WaitingMarkerEvent> {
415
- TransitionResult::ok(
416
- [],
417
- WaitingMarkerEvent {
418
- already_resolved: false,
419
- },
420
- )
421
- }
422
- }
423
-
424
- #[derive(Clone)]
425
- pub(super) struct ReplayingPreResolved {
426
- dat: ResolveDat,
427
- }
428
- impl ReplayingPreResolved {
429
- pub(super) fn on_schedule(
430
- self,
431
- ) -> LocalActivityMachineTransition<WaitingMarkerEventPreResolved> {
432
- TransitionResult::ok(
433
- [
434
- LocalActivityCommand::FakeMarker,
435
- LocalActivityCommand::Resolved(self.dat),
436
- ],
437
- WaitingMarkerEventPreResolved {},
438
- )
439
- }
440
- }
441
-
442
- #[derive(Default, Clone)]
443
- pub(super) struct RequestSent {}
444
-
445
- impl RequestSent {
446
- fn on_handle_result(
447
- self,
448
- dat: ResolveDat,
449
- ) -> LocalActivityMachineTransition<MarkerCommandCreated> {
450
- let result_type = match &dat.result {
451
- LocalActivityExecutionResult::Completed(_) => ResultType::Completed,
452
- LocalActivityExecutionResult::Failed(_) => ResultType::Failed,
453
- LocalActivityExecutionResult::TimedOut(_) => ResultType::Failed,
454
- LocalActivityExecutionResult::Cancelled { .. } => ResultType::Cancelled,
455
- };
456
- let new_state = MarkerCommandCreated { result_type };
457
- TransitionResult::ok([LocalActivityCommand::Resolved(dat)], new_state)
458
- }
459
-
460
- fn on_cancel_requested(self) -> LocalActivityMachineTransition<RequestSent> {
461
- TransitionResult::ok([LocalActivityCommand::RequestCancel], self)
462
- }
463
-
464
- fn on_no_wait_cancel(
465
- self,
466
- shared: SharedState,
467
- cancel_type: ActivityCancellationType,
468
- ) -> LocalActivityMachineTransition<MarkerCommandCreated> {
469
- let mut cmds = vec![];
470
- if matches!(cancel_type, ActivityCancellationType::TryCancel) {
471
- // For try-cancels also request the cancel
472
- cmds.push(LocalActivityCommand::RequestCancel);
473
- }
474
- // Immediately resolve
475
- cmds.push(LocalActivityCommand::Resolved(
476
- shared.produce_no_wait_cancel_resolve_dat(),
477
- ));
478
- TransitionResult::ok(
479
- cmds,
480
- MarkerCommandCreated {
481
- result_type: ResultType::Cancelled,
482
- },
483
- )
484
- }
485
- }
486
-
487
- macro_rules! verify_marker_dat {
488
- ($shared:expr, $dat:expr, $ok_expr:expr) => {
489
- if let Err(err) = verify_marker_data_matches($shared, $dat) {
490
- TransitionResult::Err(err)
491
- } else {
492
- $ok_expr
493
- }
494
- };
495
- }
496
-
497
- #[derive(Clone)]
498
- pub(super) struct ResultNotified {
499
- result_type: ResultType,
500
- }
501
-
502
- impl ResultNotified {
503
- pub(super) fn on_marker_recorded(
504
- self,
505
- shared: SharedState,
506
- dat: CompleteLocalActivityData,
507
- ) -> LocalActivityMachineTransition<MarkerCommandRecorded> {
508
- if self.result_type == ResultType::Completed && dat.result.is_err() {
509
- return TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
510
- "Local activity (seq {}) completed successfully locally, but history said \
511
- it failed!",
512
- shared.attrs.seq
513
- )));
514
- } else if self.result_type == ResultType::Failed && dat.result.is_ok() {
515
- return TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
516
- "Local activity (seq {}) failed locally, but history said it completed!",
517
- shared.attrs.seq
518
- )));
519
- }
520
- verify_marker_dat!(&shared, &dat, TransitionResult::default())
521
- }
522
- }
523
-
524
- #[derive(Default, Clone)]
525
- pub(super) struct WaitingMarkerEvent {
526
- already_resolved: bool,
527
- }
528
-
529
- impl WaitingMarkerEvent {
530
- pub(super) fn on_marker_recorded(
531
- self,
532
- shared: SharedState,
533
- dat: CompleteLocalActivityData,
534
- ) -> LocalActivityMachineTransition<MarkerCommandRecorded> {
535
- verify_marker_dat!(
536
- &shared,
537
- &dat,
538
- TransitionResult::commands(if self.already_resolved {
539
- vec![]
540
- } else {
541
- vec![LocalActivityCommand::Resolved(dat.into())]
542
- })
543
- )
544
- }
545
- fn on_handle_result(
546
- self,
547
- dat: ResolveDat,
548
- ) -> LocalActivityMachineTransition<WaitingMarkerEvent> {
549
- TransitionResult::ok(
550
- [LocalActivityCommand::Resolved(dat)],
551
- WaitingMarkerEvent {
552
- already_resolved: true,
553
- },
554
- )
555
- }
556
- pub(super) fn on_started_non_replay_wft(
557
- self,
558
- mut dat: SharedState,
559
- ) -> LocalActivityMachineTransition<RequestSent> {
560
- // We aren't really "replaying" anymore for our purposes, and want to record the marker.
561
- dat.replaying_when_invoked = false;
562
- TransitionResult::ok_shared(
563
- [LocalActivityCommand::RequestActivityExecution(
564
- dat.attrs.clone(),
565
- )],
566
- RequestSent::default(),
567
- dat,
568
- )
569
- }
570
-
571
- fn on_cancel_requested(self) -> LocalActivityMachineTransition<WaitingMarkerEvent> {
572
- // We still "request a cancel" even though we know the local activity should not be running
573
- // because the data might be in the pre-resolved list.
574
- TransitionResult::ok([LocalActivityCommand::RequestCancel], self)
575
- }
576
-
577
- fn on_no_wait_cancel(
578
- self,
579
- _: ActivityCancellationType,
580
- ) -> LocalActivityMachineTransition<WaitingMarkerEvent> {
581
- // Markers are always recorded when cancelling, so this is the same as a normal cancel on
582
- // the replay path
583
- self.on_cancel_requested()
584
- }
585
- }
586
-
587
- #[derive(Default, Clone)]
588
- pub(super) struct WaitingMarkerEventPreResolved {}
589
- impl WaitingMarkerEventPreResolved {
590
- pub(super) fn on_marker_recorded(
591
- self,
592
- shared: SharedState,
593
- dat: CompleteLocalActivityData,
594
- ) -> LocalActivityMachineTransition<MarkerCommandRecorded> {
595
- verify_marker_dat!(&shared, &dat, TransitionResult::default())
596
- }
597
- }
598
-
599
- impl Cancellable for LocalActivityMachine {
600
- fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<Self::Error>> {
601
- let event = match self.shared_state.attrs.cancellation_type {
602
- ct @ ActivityCancellationType::TryCancel | ct @ ActivityCancellationType::Abandon => {
603
- LocalActivityMachineEvents::NoWaitCancel(ct)
604
- }
605
- _ => LocalActivityMachineEvents::Cancel,
606
- };
607
- let cmds = OnEventWrapper::on_event_mut(self, event)?;
608
- let mach_resps = cmds
609
- .into_iter()
610
- .map(|mc| self.adapt_response(mc, None))
611
- .collect::<Result<Vec<_>, _>>()?
612
- .into_iter()
613
- .flatten()
614
- .collect();
615
- Ok(mach_resps)
616
- }
617
-
618
- fn was_cancelled_before_sent_to_server(&self) -> bool {
619
- // This needs to always be false because for the situation where we cancel in the same WFT,
620
- // no command of any kind is created and no LA request is queued. Otherwise, the command we
621
- // create to record a cancel marker *needs* to be sent to the server still, which returning
622
- // true here would prevent.
623
- false
624
- }
625
- }
626
-
627
- #[derive(Default, Clone)]
628
- pub(super) struct Abandoned {}
629
-
630
- impl WFMachinesAdapter for LocalActivityMachine {
631
- fn adapt_response(
632
- &self,
633
- my_command: Self::Command,
634
- _event_info: Option<EventInfo>,
635
- ) -> Result<Vec<MachineResponse>, WFMachinesError> {
636
- match my_command {
637
- LocalActivityCommand::RequestActivityExecution(act) => {
638
- Ok(vec![MachineResponse::QueueLocalActivity(act)])
639
- }
640
- LocalActivityCommand::Resolved(ResolveDat {
641
- result,
642
- complete_time,
643
- attempt,
644
- backoff,
645
- original_schedule_time,
646
- }) => {
647
- let mut maybe_ok_result = None;
648
- let mut maybe_failure = None;
649
- // Only issue record marker commands if we weren't replaying
650
- let record_marker = !self.shared_state.replaying_when_invoked;
651
- let mut will_not_run_again = false;
652
- match result.clone() {
653
- LocalActivityExecutionResult::Completed(suc) => {
654
- maybe_ok_result = suc.result;
655
- }
656
- LocalActivityExecutionResult::Failed(fail) => {
657
- maybe_failure = fail.failure;
658
- }
659
- LocalActivityExecutionResult::Cancelled(Cancellation { failure })
660
- | LocalActivityExecutionResult::TimedOut(ActFail { failure }) => {
661
- will_not_run_again = true;
662
- maybe_failure = failure;
663
- }
664
- };
665
- let resolution = if let Some(b) = backoff.as_ref() {
666
- ActivityResolution {
667
- status: Some(
668
- DoBackoff {
669
- attempt: attempt + 1,
670
- backoff_duration: Some(b.clone()),
671
- original_schedule_time: original_schedule_time.map(Into::into),
672
- }
673
- .into(),
674
- ),
675
- }
676
- } else {
677
- result.into()
678
- };
679
- let mut responses = vec![
680
- MachineResponse::PushWFJob(OutgoingJob {
681
- variant: ResolveActivity {
682
- seq: self.shared_state.attrs.seq,
683
- result: Some(resolution),
684
- }
685
- .into(),
686
- is_la_resolution: true,
687
- }),
688
- MachineResponse::UpdateWFTime(complete_time),
689
- ];
690
-
691
- // Cancel-resolves of abandoned activities must be explicitly dropped from tracking
692
- // to avoid unnecessary WFT heartbeating.
693
- if will_not_run_again
694
- && matches!(
695
- self.shared_state.attrs.cancellation_type,
696
- ActivityCancellationType::Abandon
697
- )
698
- {
699
- responses.push(MachineResponse::AbandonLocalActivity(
700
- self.shared_state.attrs.seq,
701
- ));
702
- }
703
-
704
- if record_marker {
705
- let marker_data = RecordMarkerCommandAttributes {
706
- marker_name: LOCAL_ACTIVITY_MARKER_NAME.to_string(),
707
- details: build_local_activity_marker_details(
708
- LocalActivityMarkerData {
709
- seq: self.shared_state.attrs.seq,
710
- attempt,
711
- activity_id: self.shared_state.attrs.activity_id.clone(),
712
- activity_type: self.shared_state.attrs.activity_type.clone(),
713
- complete_time: complete_time.map(Into::into),
714
- backoff,
715
- original_schedule_time: original_schedule_time.map(Into::into),
716
- },
717
- maybe_ok_result,
718
- ),
719
- header: None,
720
- failure: maybe_failure,
721
- };
722
- responses.push(MachineResponse::IssueNewCommand(Command {
723
- command_type: CommandType::RecordMarker as i32,
724
- attributes: Some(marker_data.into()),
725
- }));
726
- }
727
- Ok(responses)
728
- }
729
- LocalActivityCommand::FakeMarker => {
730
- // See docs for `FakeMarker` for more
731
- Ok(vec![MachineResponse::IssueFakeLocalActivityMarker(
732
- self.shared_state.attrs.seq,
733
- )])
734
- }
735
- LocalActivityCommand::RequestCancel => {
736
- Ok(vec![MachineResponse::RequestCancelLocalActivity(
737
- self.shared_state.attrs.seq,
738
- )])
739
- }
740
- }
741
- }
742
-
743
- fn matches_event(&self, event: &HistoryEvent) -> bool {
744
- event.is_local_activity_marker()
745
- }
746
- }
747
-
748
- impl TryFrom<CommandType> for LocalActivityMachineEvents {
749
- type Error = ();
750
-
751
- fn try_from(c: CommandType) -> Result<Self, Self::Error> {
752
- Ok(match c {
753
- CommandType::RecordMarker => Self::CommandRecordMarker,
754
- _ => return Err(()),
755
- })
756
- }
757
- }
758
-
759
- impl TryFrom<HistEventData> for LocalActivityMachineEvents {
760
- type Error = WFMachinesError;
761
-
762
- fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
763
- let e = e.event;
764
- if e.event_type() != EventType::MarkerRecorded {
765
- return Err(WFMachinesError::Nondeterminism(format!(
766
- "Local activity machine cannot handle this event: {e}"
767
- )));
768
- }
769
-
770
- match e.into_local_activity_marker_details() {
771
- Some(marker_dat) => Ok(LocalActivityMachineEvents::MarkerRecorded(marker_dat)),
772
- _ => Err(WFMachinesError::Nondeterminism(
773
- "Local activity machine encountered an unparsable marker".to_string(),
774
- )),
775
- }
776
- }
777
- }
778
-
779
- fn verify_marker_data_matches(
780
- shared: &SharedState,
781
- dat: &CompleteLocalActivityData,
782
- ) -> Result<(), WFMachinesError> {
783
- if shared.attrs.seq != dat.marker_dat.seq {
784
- return Err(WFMachinesError::Nondeterminism(format!(
785
- "Local activity marker data has sequence number {} but matched against LA \
786
- command with sequence number {}",
787
- dat.marker_dat.seq, shared.attrs.seq
788
- )));
789
- }
790
- // Here we use whether or not we were replaying when we _first invoked_ the LA, because we
791
- // are always replaying when we see the marker recorded event, and that would make this check
792
- // a bit pointless.
793
- if shared.internal_flags.borrow_mut().try_use(
794
- CoreInternalFlags::IdAndTypeDeterminismChecks,
795
- !shared.replaying_when_invoked,
796
- ) {
797
- if dat.marker_dat.activity_id != shared.attrs.activity_id {
798
- return Err(WFMachinesError::Nondeterminism(format!(
799
- "Activity id of recorded marker '{}' does not \
800
- match activity id of local activity command '{}'",
801
- dat.marker_dat.activity_id, shared.attrs.activity_id
802
- )));
803
- }
804
- if dat.marker_dat.activity_type != shared.attrs.activity_type {
805
- return Err(WFMachinesError::Nondeterminism(format!(
806
- "Activity type of recorded marker '{}' does not \
807
- match activity type of local activity command '{}'",
808
- dat.marker_dat.activity_type, shared.attrs.activity_type
809
- )));
810
- }
811
- }
812
-
813
- Ok(())
814
- }
815
-
816
- impl From<LocalActivityExecutionResult> for ActivityResolution {
817
- fn from(lar: LocalActivityExecutionResult) -> Self {
818
- match lar {
819
- LocalActivityExecutionResult::Completed(c) => ActivityResolution {
820
- status: Some(c.into()),
821
- },
822
- LocalActivityExecutionResult::Failed(f) | LocalActivityExecutionResult::TimedOut(f) => {
823
- ActivityResolution {
824
- status: Some(f.into()),
825
- }
826
- }
827
- LocalActivityExecutionResult::Cancelled(cancel) => ActivityResolution {
828
- status: Some(cancel.into()),
829
- },
830
- }
831
- }
832
- }
833
-
834
- #[cfg(test)]
835
- mod tests {
836
- use super::*;
837
- use crate::{
838
- replay::TestHistoryBuilder, test_help::canned_histories, worker::workflow::ManagedWFFunc,
839
- };
840
- use rstest::rstest;
841
- use std::time::Duration;
842
- use temporal_sdk::{
843
- CancellableFuture, LocalActivityOptions, WfContext, WorkflowFunction, WorkflowResult,
844
- };
845
- use temporal_sdk_core_protos::{
846
- coresdk::{
847
- activity_result::ActivityExecutionResult,
848
- workflow_activation::{workflow_activation_job, WorkflowActivationJob},
849
- workflow_commands::ActivityCancellationType::WaitCancellationCompleted,
850
- },
851
- temporal::api::{
852
- command::v1::command, enums::v1::WorkflowTaskFailedCause, failure::v1::Failure,
853
- },
854
- DEFAULT_ACTIVITY_TYPE,
855
- };
856
-
857
- async fn la_wf(ctx: WfContext) -> WorkflowResult<()> {
858
- ctx.local_activity(LocalActivityOptions {
859
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
860
- ..Default::default()
861
- })
862
- .await;
863
- Ok(().into())
864
- }
865
-
866
- #[rstest]
867
- #[case::incremental(false, true)]
868
- #[case::replay(true, true)]
869
- #[case::incremental_fail(false, false)]
870
- #[case::replay_fail(true, false)]
871
- #[tokio::test]
872
- async fn one_la_success(#[case] replay: bool, #[case] completes_ok: bool) {
873
- let func = WorkflowFunction::new(la_wf);
874
- let activity_id = "1";
875
- let mut t = TestHistoryBuilder::default();
876
- t.add_by_type(EventType::WorkflowExecutionStarted);
877
- t.add_full_wf_task();
878
- if completes_ok {
879
- t.add_local_activity_result_marker(1, activity_id, b"hi".into());
880
- } else {
881
- t.add_local_activity_fail_marker(
882
- 1,
883
- activity_id,
884
- Failure::application_failure("I failed".to_string(), false),
885
- );
886
- }
887
- t.add_workflow_execution_completed();
888
-
889
- let histinfo = if replay {
890
- t.get_full_history_info().unwrap().into()
891
- } else {
892
- t.get_history_info(1).unwrap().into()
893
- };
894
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
895
-
896
- // First activation will have no server commands. Activity will be put into the activity
897
- // queue locally
898
- wfm.get_next_activation().await.unwrap();
899
- let commands = wfm.get_server_commands().commands;
900
- assert_eq!(commands.len(), 0);
901
-
902
- let ready_to_execute_las = wfm.drain_queued_local_activities();
903
- if !replay {
904
- assert_eq!(ready_to_execute_las.len(), 1);
905
- } else {
906
- assert_eq!(ready_to_execute_las.len(), 0);
907
- }
908
-
909
- if !replay {
910
- if completes_ok {
911
- wfm.complete_local_activity(1, ActivityExecutionResult::ok(b"hi".into()))
912
- .unwrap();
913
- } else {
914
- wfm.complete_local_activity(
915
- 1,
916
- ActivityExecutionResult::fail(Failure {
917
- message: "I failed".to_string(),
918
- ..Default::default()
919
- }),
920
- )
921
- .unwrap();
922
- }
923
- }
924
-
925
- // Now the next activation will unblock the local activity
926
- wfm.get_next_activation().await.unwrap();
927
- let commands = wfm.get_server_commands().commands;
928
- if replay {
929
- assert_eq!(commands.len(), 1);
930
- assert_eq!(
931
- commands[0].command_type,
932
- CommandType::CompleteWorkflowExecution as i32
933
- );
934
- } else {
935
- assert_eq!(commands.len(), 2);
936
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
937
- if completes_ok {
938
- assert_matches!(
939
- commands[0].attributes.as_ref().unwrap(),
940
- command::Attributes::RecordMarkerCommandAttributes(
941
- RecordMarkerCommandAttributes { failure: None, .. }
942
- )
943
- );
944
- } else {
945
- assert_matches!(
946
- commands[0].attributes.as_ref().unwrap(),
947
- command::Attributes::RecordMarkerCommandAttributes(
948
- RecordMarkerCommandAttributes {
949
- failure: Some(_),
950
- ..
951
- }
952
- )
953
- );
954
- }
955
- assert_eq!(
956
- commands[1].command_type,
957
- CommandType::CompleteWorkflowExecution as i32
958
- );
959
- }
960
-
961
- if !replay {
962
- wfm.new_history(t.get_full_history_info().unwrap().into())
963
- .await
964
- .unwrap();
965
- }
966
- assert_eq!(wfm.drain_queued_local_activities().len(), 0);
967
- assert_eq!(wfm.get_next_activation().await.unwrap().jobs.len(), 0);
968
- let commands = wfm.get_server_commands().commands;
969
- assert_eq!(commands.len(), 0);
970
-
971
- wfm.shutdown().await.unwrap();
972
- }
973
-
974
- async fn two_la_wf(ctx: WfContext) -> WorkflowResult<()> {
975
- ctx.local_activity(LocalActivityOptions {
976
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
977
- ..Default::default()
978
- })
979
- .await;
980
- ctx.local_activity(LocalActivityOptions {
981
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
982
- ..Default::default()
983
- })
984
- .await;
985
- Ok(().into())
986
- }
987
-
988
- #[rstest]
989
- #[case::incremental(false)]
990
- #[case::replay(true)]
991
- #[tokio::test]
992
- async fn two_sequential_las(#[case] replay: bool) {
993
- let func = WorkflowFunction::new(two_la_wf);
994
- let t = canned_histories::two_local_activities_one_wft(false);
995
- let histinfo = if replay {
996
- t.get_full_history_info().unwrap().into()
997
- } else {
998
- t.get_history_info(1).unwrap().into()
999
- };
1000
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1001
-
1002
- // First activation will have no server commands. Activity will be put into the activity
1003
- // queue locally
1004
- let act = wfm.get_next_activation().await.unwrap();
1005
- let first_act_ts = act.timestamp.unwrap();
1006
- let commands = wfm.get_server_commands().commands;
1007
- assert_eq!(commands.len(), 0);
1008
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1009
- let num_queued = usize::from(!replay);
1010
- assert_eq!(ready_to_execute_las.len(), num_queued);
1011
-
1012
- if !replay {
1013
- wfm.complete_local_activity(1, ActivityExecutionResult::ok(b"Resolved".into()))
1014
- .unwrap();
1015
- }
1016
-
1017
- let act = wfm.get_next_activation().await.unwrap();
1018
- // Verify LAs advance time (they take 1s in this test)
1019
- assert_eq!(act.timestamp.unwrap().seconds, first_act_ts.seconds + 1);
1020
- assert_matches!(
1021
- act.jobs.as_slice(),
1022
- [WorkflowActivationJob {
1023
- variant: Some(workflow_activation_job::Variant::ResolveActivity(ra))
1024
- }] => assert_eq!(ra.seq, 1)
1025
- );
1026
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1027
- if !replay {
1028
- assert_eq!(ready_to_execute_las.len(), 1);
1029
- } else {
1030
- assert_eq!(ready_to_execute_las.len(), 0);
1031
- }
1032
-
1033
- if !replay {
1034
- wfm.complete_local_activity(2, ActivityExecutionResult::ok(b"Resolved".into()))
1035
- .unwrap();
1036
- }
1037
-
1038
- let act = wfm.get_next_activation().await.unwrap();
1039
- assert_eq!(act.timestamp.unwrap().seconds, first_act_ts.seconds + 2);
1040
- assert_matches!(
1041
- act.jobs.as_slice(),
1042
- [WorkflowActivationJob {
1043
- variant: Some(workflow_activation_job::Variant::ResolveActivity(ra))
1044
- }] => assert_eq!(ra.seq, 2)
1045
- );
1046
- let commands = wfm.get_server_commands().commands;
1047
- if replay {
1048
- assert_eq!(commands.len(), 1);
1049
- assert_eq!(
1050
- commands[0].command_type,
1051
- CommandType::CompleteWorkflowExecution as i32
1052
- );
1053
- } else {
1054
- assert_eq!(commands.len(), 3);
1055
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1056
- assert_eq!(commands[1].command_type, CommandType::RecordMarker as i32);
1057
- assert_eq!(
1058
- commands[2].command_type,
1059
- CommandType::CompleteWorkflowExecution as i32
1060
- );
1061
- }
1062
-
1063
- if !replay {
1064
- wfm.new_history(t.get_full_history_info().unwrap().into())
1065
- .await
1066
- .unwrap();
1067
- }
1068
- assert_eq!(wfm.get_next_activation().await.unwrap().jobs.len(), 0);
1069
- let commands = wfm.get_server_commands().commands;
1070
- assert_eq!(commands.len(), 0);
1071
-
1072
- wfm.shutdown().await.unwrap();
1073
- }
1074
-
1075
- async fn two_la_wf_parallel(ctx: WfContext) -> WorkflowResult<()> {
1076
- tokio::join!(
1077
- ctx.local_activity(LocalActivityOptions {
1078
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
1079
- ..Default::default()
1080
- }),
1081
- ctx.local_activity(LocalActivityOptions {
1082
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
1083
- ..Default::default()
1084
- })
1085
- );
1086
- Ok(().into())
1087
- }
1088
-
1089
- #[rstest]
1090
- #[case::incremental(false)]
1091
- #[case::replay(true)]
1092
- #[tokio::test]
1093
- async fn two_parallel_las(#[case] replay: bool) {
1094
- let func = WorkflowFunction::new(two_la_wf_parallel);
1095
- let t = canned_histories::two_local_activities_one_wft(true);
1096
- let histinfo = if replay {
1097
- t.get_full_history_info().unwrap().into()
1098
- } else {
1099
- t.get_history_info(1).unwrap().into()
1100
- };
1101
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1102
-
1103
- // First activation will have no server commands. Activity(ies) will be put into the queue
1104
- // for execution
1105
- let act = wfm.get_next_activation().await.unwrap();
1106
- let first_act_ts = act.timestamp.unwrap();
1107
- let commands = wfm.get_server_commands().commands;
1108
- assert_eq!(commands.len(), 0);
1109
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1110
- let num_queued = if !replay { 2 } else { 0 };
1111
- assert_eq!(ready_to_execute_las.len(), num_queued);
1112
-
1113
- if !replay {
1114
- wfm.complete_local_activity(1, ActivityExecutionResult::ok(b"Resolved".into()))
1115
- .unwrap();
1116
- wfm.complete_local_activity(2, ActivityExecutionResult::ok(b"Resolved".into()))
1117
- .unwrap();
1118
- }
1119
-
1120
- let act = wfm.get_next_activation().await.unwrap();
1121
- assert_eq!(act.timestamp.unwrap().seconds, first_act_ts.seconds + 1);
1122
- assert_matches!(
1123
- act.jobs.as_slice(),
1124
- [WorkflowActivationJob {
1125
- variant: Some(workflow_activation_job::Variant::ResolveActivity(ra))
1126
- },
1127
- WorkflowActivationJob {
1128
- variant: Some(workflow_activation_job::Variant::ResolveActivity(ra2))
1129
- }] => {assert_eq!(ra.seq, 1); assert_eq!(ra2.seq, 2)}
1130
- );
1131
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1132
- assert_eq!(ready_to_execute_las.len(), 0);
1133
-
1134
- let commands = wfm.get_server_commands().commands;
1135
- if replay {
1136
- assert_eq!(commands.len(), 1);
1137
- assert_eq!(
1138
- commands[0].command_type,
1139
- CommandType::CompleteWorkflowExecution as i32
1140
- );
1141
- } else {
1142
- assert_eq!(commands.len(), 3);
1143
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1144
- assert_eq!(commands[1].command_type, CommandType::RecordMarker as i32);
1145
- assert_eq!(
1146
- commands[2].command_type,
1147
- CommandType::CompleteWorkflowExecution as i32
1148
- );
1149
- }
1150
-
1151
- if !replay {
1152
- wfm.new_history(t.get_full_history_info().unwrap().into())
1153
- .await
1154
- .unwrap();
1155
- }
1156
- let act = wfm.get_next_activation().await.unwrap();
1157
- // Still only 1s ahead b/c parallel
1158
- assert_eq!(act.timestamp.unwrap().seconds, first_act_ts.seconds + 1);
1159
- assert_eq!(act.jobs.len(), 0);
1160
- let commands = wfm.get_server_commands().commands;
1161
- assert_eq!(commands.len(), 0);
1162
-
1163
- wfm.shutdown().await.unwrap();
1164
- }
1165
-
1166
- async fn la_timer_la(ctx: WfContext) -> WorkflowResult<()> {
1167
- ctx.local_activity(LocalActivityOptions {
1168
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
1169
- ..Default::default()
1170
- })
1171
- .await;
1172
- ctx.timer(Duration::from_secs(5)).await;
1173
- ctx.local_activity(LocalActivityOptions {
1174
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
1175
- ..Default::default()
1176
- })
1177
- .await;
1178
- Ok(().into())
1179
- }
1180
-
1181
- #[rstest]
1182
- #[case::incremental(false)]
1183
- #[case::replay(true)]
1184
- #[tokio::test]
1185
- async fn las_separated_by_timer(#[case] replay: bool) {
1186
- let func = WorkflowFunction::new(la_timer_la);
1187
- let t = canned_histories::two_local_activities_separated_by_timer();
1188
- let histinfo = if replay {
1189
- t.get_full_history_info().unwrap().into()
1190
- } else {
1191
- t.get_history_info(1).unwrap().into()
1192
- };
1193
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1194
-
1195
- wfm.get_next_activation().await.unwrap();
1196
- let commands = wfm.get_server_commands().commands;
1197
- assert_eq!(commands.len(), 0);
1198
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1199
- let num_queued = usize::from(!replay);
1200
- assert_eq!(ready_to_execute_las.len(), num_queued);
1201
-
1202
- if !replay {
1203
- wfm.complete_local_activity(1, ActivityExecutionResult::ok(b"Resolved".into()))
1204
- .unwrap();
1205
- }
1206
-
1207
- let act = wfm.get_next_activation().await.unwrap();
1208
- assert_matches!(
1209
- act.jobs.as_slice(),
1210
- [WorkflowActivationJob {
1211
- variant: Some(workflow_activation_job::Variant::ResolveActivity(ra))
1212
- }] => assert_eq!(ra.seq, 1)
1213
- );
1214
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1215
- assert_eq!(ready_to_execute_las.len(), 0);
1216
-
1217
- let commands = wfm.get_server_commands().commands;
1218
- if replay {
1219
- assert_eq!(commands.len(), 1);
1220
- assert_eq!(commands[0].command_type, CommandType::StartTimer as i32);
1221
- } else {
1222
- assert_eq!(commands.len(), 2);
1223
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1224
- assert_eq!(commands[1].command_type, CommandType::StartTimer as i32);
1225
- }
1226
-
1227
- let act = if !replay {
1228
- wfm.new_history(t.get_history_info(2).unwrap().into())
1229
- .await
1230
- .unwrap()
1231
- } else {
1232
- wfm.get_next_activation().await.unwrap()
1233
- };
1234
- assert_matches!(
1235
- act.jobs.as_slice(),
1236
- [WorkflowActivationJob {
1237
- variant: Some(workflow_activation_job::Variant::FireTimer(_))
1238
- }]
1239
- );
1240
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1241
- let num_queued = usize::from(!replay);
1242
- assert_eq!(ready_to_execute_las.len(), num_queued);
1243
- if !replay {
1244
- wfm.complete_local_activity(2, ActivityExecutionResult::ok(b"Resolved".into()))
1245
- .unwrap();
1246
- }
1247
-
1248
- let act = wfm.get_next_activation().await.unwrap();
1249
- assert_matches!(
1250
- act.jobs.as_slice(),
1251
- [WorkflowActivationJob {
1252
- variant: Some(workflow_activation_job::Variant::ResolveActivity(ra))
1253
- }] => assert_eq!(ra.seq, 2)
1254
- );
1255
-
1256
- let commands = wfm.get_server_commands().commands;
1257
- if replay {
1258
- assert_eq!(commands.len(), 1);
1259
- assert_eq!(
1260
- commands[0].command_type,
1261
- CommandType::CompleteWorkflowExecution as i32
1262
- );
1263
- } else {
1264
- assert_eq!(commands.len(), 2);
1265
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1266
- assert_eq!(
1267
- commands[1].command_type,
1268
- CommandType::CompleteWorkflowExecution as i32
1269
- );
1270
- }
1271
-
1272
- wfm.shutdown().await.unwrap();
1273
- }
1274
-
1275
- #[tokio::test]
1276
- async fn one_la_heartbeating_wft_failure_still_executes() {
1277
- let func = WorkflowFunction::new(la_wf);
1278
- let mut t = TestHistoryBuilder::default();
1279
- t.add_by_type(EventType::WorkflowExecutionStarted);
1280
- // Heartbeats
1281
- t.add_full_wf_task();
1282
- // fails a wft for some reason
1283
- t.add_workflow_task_scheduled_and_started();
1284
- t.add_workflow_task_failed_with_failure(
1285
- WorkflowTaskFailedCause::NonDeterministicError,
1286
- Default::default(),
1287
- );
1288
- t.add_workflow_task_scheduled_and_started();
1289
-
1290
- let histinfo = t.get_full_history_info().unwrap().into();
1291
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1292
-
1293
- // First activation will request to run the LA since the heartbeat & wft failure are skipped
1294
- // over
1295
- wfm.get_next_activation().await.unwrap();
1296
- let commands = wfm.get_server_commands().commands;
1297
- assert_eq!(commands.len(), 0);
1298
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1299
- assert_eq!(ready_to_execute_las.len(), 1);
1300
- // We can happily complete it now
1301
- wfm.complete_local_activity(1, ActivityExecutionResult::ok(b"hi".into()))
1302
- .unwrap();
1303
-
1304
- wfm.shutdown().await.unwrap();
1305
- }
1306
-
1307
- /// This test verifies something that technically shouldn't really be possible but is worth
1308
- /// checking anyway. What happens if in memory we think an LA passed but then the next history
1309
- /// chunk comes back with it failing? We should fail with a mismatch.
1310
- #[tokio::test]
1311
- async fn exec_passes_but_history_has_fail() {
1312
- let func = WorkflowFunction::new(la_wf);
1313
- let mut t = TestHistoryBuilder::default();
1314
- t.add_by_type(EventType::WorkflowExecutionStarted);
1315
- t.add_full_wf_task();
1316
- t.add_local_activity_fail_marker(
1317
- 1,
1318
- "1",
1319
- Failure::application_failure("I failed".to_string(), false),
1320
- );
1321
- t.add_workflow_execution_completed();
1322
-
1323
- let histinfo = t.get_history_info(1).unwrap().into();
1324
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1325
-
1326
- wfm.get_next_activation().await.unwrap();
1327
- let commands = wfm.get_server_commands().commands;
1328
- assert_eq!(commands.len(), 0);
1329
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1330
- assert_eq!(ready_to_execute_las.len(), 1);
1331
- // Completes OK
1332
- wfm.complete_local_activity(1, ActivityExecutionResult::ok(b"hi".into()))
1333
- .unwrap();
1334
-
1335
- // next activation unblocks LA
1336
- wfm.get_next_activation().await.unwrap();
1337
- let commands = wfm.get_server_commands().commands;
1338
- assert_eq!(commands.len(), 2);
1339
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1340
- assert_eq!(
1341
- commands[1].command_type,
1342
- CommandType::CompleteWorkflowExecution as i32
1343
- );
1344
-
1345
- let err = wfm
1346
- .new_history(t.get_full_history_info().unwrap().into())
1347
- .await
1348
- .unwrap_err();
1349
- assert!(err.to_string().contains("Nondeterminism"));
1350
- wfm.shutdown().await.unwrap();
1351
- }
1352
-
1353
- #[rstest]
1354
- #[tokio::test]
1355
- async fn immediate_cancel(
1356
- #[values(
1357
- ActivityCancellationType::WaitCancellationCompleted,
1358
- ActivityCancellationType::TryCancel,
1359
- ActivityCancellationType::Abandon
1360
- )]
1361
- cancel_type: ActivityCancellationType,
1362
- ) {
1363
- let func = WorkflowFunction::new(move |ctx| async move {
1364
- let la = ctx.local_activity(LocalActivityOptions {
1365
- cancel_type,
1366
- ..Default::default()
1367
- });
1368
- la.cancel(&ctx);
1369
- la.await;
1370
- Ok(().into())
1371
- });
1372
- let mut t = TestHistoryBuilder::default();
1373
- t.add_by_type(EventType::WorkflowExecutionStarted);
1374
- t.add_full_wf_task();
1375
- t.add_workflow_execution_completed();
1376
-
1377
- let histinfo = t.get_history_info(1).unwrap().into();
1378
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1379
-
1380
- wfm.get_next_activation().await.unwrap();
1381
- let commands = wfm.get_server_commands().commands;
1382
- assert_eq!(commands.len(), 1);
1383
- // We record the cancel marker
1384
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1385
- // Importantly, the activity shouldn't get executed since it was insta-cancelled
1386
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1387
- assert_eq!(ready_to_execute_las.len(), 0);
1388
-
1389
- // next activation unblocks LA, which is cancelled now.
1390
- wfm.get_next_activation().await.unwrap();
1391
- let commands = wfm.get_server_commands().commands;
1392
- assert_eq!(commands.len(), 2);
1393
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1394
- assert_eq!(
1395
- commands[1].command_type,
1396
- CommandType::CompleteWorkflowExecution as i32
1397
- );
1398
-
1399
- wfm.shutdown().await.unwrap();
1400
- }
1401
-
1402
- #[rstest]
1403
- #[case::incremental(false)]
1404
- #[case::replay(true)]
1405
- #[tokio::test]
1406
- async fn cancel_after_act_starts(
1407
- #[case] replay: bool,
1408
- #[values(
1409
- ActivityCancellationType::WaitCancellationCompleted,
1410
- ActivityCancellationType::TryCancel,
1411
- ActivityCancellationType::Abandon
1412
- )]
1413
- cancel_type: ActivityCancellationType,
1414
- ) {
1415
- let func = WorkflowFunction::new(move |ctx| async move {
1416
- let la = ctx.local_activity(LocalActivityOptions {
1417
- cancel_type,
1418
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
1419
- ..Default::default()
1420
- });
1421
- ctx.timer(Duration::from_secs(1)).await;
1422
- la.cancel(&ctx);
1423
- // This extra timer is here to ensure the presence of another WF task doesn't mess up
1424
- // resolving the LA with cancel on replay
1425
- ctx.timer(Duration::from_secs(1)).await;
1426
- let resolution = la.await;
1427
- assert!(resolution.cancelled());
1428
- Ok(().into())
1429
- });
1430
-
1431
- let mut t = TestHistoryBuilder::default();
1432
- t.add_by_type(EventType::WorkflowExecutionStarted);
1433
- t.add_full_wf_task();
1434
- let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
1435
- t.add_timer_fired(timer_started_event_id, "1".to_string());
1436
- t.add_full_wf_task();
1437
- if cancel_type != ActivityCancellationType::WaitCancellationCompleted {
1438
- // With non-wait cancels, the cancel is immediate
1439
- t.add_local_activity_cancel_marker(1, "1");
1440
- }
1441
- let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
1442
- if cancel_type == ActivityCancellationType::WaitCancellationCompleted {
1443
- // With wait cancels, the cancel marker is not recorded until activity reports.
1444
- t.add_local_activity_cancel_marker(1, "1");
1445
- }
1446
- t.add_timer_fired(timer_started_event_id, "2".to_string());
1447
- t.add_full_wf_task();
1448
- t.add_workflow_execution_completed();
1449
-
1450
- let histinfo = if replay {
1451
- t.get_full_history_info().unwrap().into()
1452
- } else {
1453
- t.get_history_info(1).unwrap().into()
1454
- };
1455
- let mut wfm = ManagedWFFunc::new_from_update(histinfo, func, vec![]);
1456
-
1457
- wfm.get_next_activation().await.unwrap();
1458
- let commands = wfm.get_server_commands().commands;
1459
- assert_eq!(commands.len(), 1);
1460
- assert_eq!(commands[0].command_type, CommandType::StartTimer as i32);
1461
- let ready_to_execute_las = wfm.drain_queued_local_activities();
1462
- let num_queued = usize::from(!replay);
1463
- assert_eq!(ready_to_execute_las.len(), num_queued);
1464
-
1465
- // Next activation timer fires and activity cancel will be requested
1466
- if replay {
1467
- wfm.get_next_activation().await.unwrap()
1468
- } else {
1469
- wfm.new_history(t.get_history_info(2).unwrap().into())
1470
- .await
1471
- .unwrap()
1472
- };
1473
-
1474
- let commands = wfm.get_server_commands().commands;
1475
- if cancel_type == ActivityCancellationType::WaitCancellationCompleted || replay {
1476
- assert_eq!(commands.len(), 1);
1477
- assert_eq!(commands[0].command_type, CommandType::StartTimer as i32);
1478
- } else {
1479
- // Try-cancel/abandon will immediately record marker (when not replaying)
1480
- assert_eq!(commands.len(), 2);
1481
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1482
- assert_eq!(commands[1].command_type, CommandType::StartTimer as i32);
1483
- }
1484
-
1485
- let commands = if replay {
1486
- wfm.get_next_activation().await.unwrap();
1487
- wfm.get_server_commands().commands
1488
- } else {
1489
- // On non replay, there's an additional activation, because completing with the cancel
1490
- // wants to wake up the workflow to see if resolving the LA as cancelled did anything.
1491
- // In this case, it doesn't really, because we just hit the next timer which is also
1492
- // what would have happened if we woke up with new history -- but it does mean we
1493
- // generate the commands at this point. This matters b/c we want to make sure the record
1494
- // marker command is sent as soon as cancel happens.
1495
- if cancel_type == WaitCancellationCompleted {
1496
- wfm.complete_local_activity(1, ActivityExecutionResult::cancel_from_details(None))
1497
- .unwrap();
1498
- }
1499
- wfm.get_next_activation().await.unwrap();
1500
- let commands = wfm.get_server_commands().commands;
1501
- assert_eq!(commands.len(), 2);
1502
- if cancel_type == ActivityCancellationType::WaitCancellationCompleted {
1503
- assert_eq!(commands[0].command_type, CommandType::StartTimer as i32);
1504
- assert_eq!(commands[1].command_type, CommandType::RecordMarker as i32);
1505
- } else {
1506
- assert_eq!(commands[0].command_type, CommandType::RecordMarker as i32);
1507
- assert_eq!(commands[1].command_type, CommandType::StartTimer as i32);
1508
- }
1509
-
1510
- wfm.new_history(t.get_history_info(3).unwrap().into())
1511
- .await
1512
- .unwrap();
1513
- wfm.get_next_activation().await.unwrap();
1514
- wfm.get_server_commands().commands
1515
- };
1516
-
1517
- assert_eq!(commands.len(), 1);
1518
- assert_eq!(
1519
- commands[0].command_type,
1520
- CommandType::CompleteWorkflowExecution as i32
1521
- );
1522
-
1523
- wfm.shutdown().await.unwrap();
1524
- }
1525
- }