temporalio 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (469) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +4035 -0
  3. data/Cargo.toml +25 -0
  4. data/Gemfile +20 -0
  5. data/LICENSE +16 -15
  6. data/README.md +455 -195
  7. data/Rakefile +387 -0
  8. data/ext/Cargo.toml +25 -0
  9. data/lib/temporalio/activity/complete_async_error.rb +11 -0
  10. data/lib/temporalio/activity/context.rb +82 -77
  11. data/lib/temporalio/activity/definition.rb +77 -0
  12. data/lib/temporalio/activity/info.rb +42 -46
  13. data/lib/temporalio/activity.rb +49 -65
  14. data/lib/temporalio/api/batch/v1/message.rb +31 -0
  15. data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +93 -0
  16. data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +25 -0
  17. data/lib/temporalio/api/cloud/cloudservice.rb +3 -0
  18. data/lib/temporalio/api/cloud/identity/v1/message.rb +36 -0
  19. data/lib/temporalio/api/cloud/namespace/v1/message.rb +35 -0
  20. data/lib/temporalio/api/cloud/operation/v1/message.rb +27 -0
  21. data/lib/temporalio/api/cloud/region/v1/message.rb +23 -0
  22. data/lib/temporalio/api/command/v1/message.rb +46 -0
  23. data/lib/temporalio/api/common/v1/grpc_status.rb +23 -0
  24. data/lib/temporalio/api/common/v1/message.rb +41 -0
  25. data/lib/temporalio/api/enums/v1/batch_operation.rb +22 -0
  26. data/lib/temporalio/api/enums/v1/command_type.rb +21 -0
  27. data/lib/temporalio/api/enums/v1/common.rb +26 -0
  28. data/lib/temporalio/api/enums/v1/event_type.rb +21 -0
  29. data/lib/temporalio/api/enums/v1/failed_cause.rb +26 -0
  30. data/lib/temporalio/api/enums/v1/namespace.rb +23 -0
  31. data/lib/temporalio/api/enums/v1/query.rb +22 -0
  32. data/lib/temporalio/api/enums/v1/reset.rb +23 -0
  33. data/lib/temporalio/api/enums/v1/schedule.rb +21 -0
  34. data/lib/temporalio/api/enums/v1/task_queue.rb +25 -0
  35. data/lib/temporalio/api/enums/v1/update.rb +22 -0
  36. data/lib/temporalio/api/enums/v1/workflow.rb +30 -0
  37. data/lib/temporalio/api/errordetails/v1/message.rb +42 -0
  38. data/lib/temporalio/api/export/v1/message.rb +24 -0
  39. data/lib/temporalio/api/failure/v1/message.rb +35 -0
  40. data/lib/temporalio/api/filter/v1/message.rb +27 -0
  41. data/lib/temporalio/api/history/v1/message.rb +90 -0
  42. data/lib/temporalio/api/namespace/v1/message.rb +31 -0
  43. data/lib/temporalio/api/nexus/v1/message.rb +40 -0
  44. data/lib/temporalio/api/operatorservice/v1/request_response.rb +49 -0
  45. data/lib/temporalio/api/operatorservice/v1/service.rb +23 -0
  46. data/lib/temporalio/api/operatorservice.rb +3 -0
  47. data/lib/temporalio/api/protocol/v1/message.rb +23 -0
  48. data/lib/temporalio/api/query/v1/message.rb +27 -0
  49. data/lib/temporalio/api/replication/v1/message.rb +26 -0
  50. data/lib/temporalio/api/schedule/v1/message.rb +42 -0
  51. data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +25 -0
  52. data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +21 -0
  53. data/lib/temporalio/api/sdk/v1/user_metadata.rb +23 -0
  54. data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +23 -0
  55. data/lib/temporalio/api/taskqueue/v1/message.rb +45 -0
  56. data/lib/temporalio/api/update/v1/message.rb +33 -0
  57. data/lib/temporalio/api/version/v1/message.rb +26 -0
  58. data/lib/temporalio/api/workflow/v1/message.rb +43 -0
  59. data/lib/temporalio/api/workflowservice/v1/request_response.rb +189 -0
  60. data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
  61. data/lib/temporalio/api/workflowservice.rb +3 -0
  62. data/lib/temporalio/api.rb +13 -0
  63. data/lib/temporalio/cancellation.rb +150 -0
  64. data/lib/temporalio/client/activity_id_reference.rb +32 -0
  65. data/lib/temporalio/client/async_activity_handle.rb +110 -0
  66. data/lib/temporalio/client/connection/cloud_service.rb +648 -0
  67. data/lib/temporalio/client/connection/operator_service.rb +249 -0
  68. data/lib/temporalio/client/connection/service.rb +41 -0
  69. data/lib/temporalio/client/connection/workflow_service.rb +1218 -0
  70. data/lib/temporalio/client/connection.rb +270 -0
  71. data/lib/temporalio/client/interceptor.rb +316 -0
  72. data/lib/temporalio/client/workflow_execution.rb +103 -0
  73. data/lib/temporalio/client/workflow_execution_count.rb +36 -0
  74. data/lib/temporalio/client/workflow_execution_status.rb +18 -0
  75. data/lib/temporalio/client/workflow_handle.rb +380 -177
  76. data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
  77. data/lib/temporalio/client/workflow_update_handle.rb +67 -0
  78. data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
  79. data/lib/temporalio/client.rb +366 -93
  80. data/lib/temporalio/common_enums.rb +24 -0
  81. data/lib/temporalio/converters/data_converter.rb +102 -0
  82. data/lib/temporalio/converters/failure_converter.rb +200 -0
  83. data/lib/temporalio/converters/payload_codec.rb +26 -0
  84. data/lib/temporalio/converters/payload_converter/binary_null.rb +34 -0
  85. data/lib/temporalio/converters/payload_converter/binary_plain.rb +35 -0
  86. data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +42 -0
  87. data/lib/temporalio/converters/payload_converter/composite.rb +62 -0
  88. data/lib/temporalio/converters/payload_converter/encoding.rb +35 -0
  89. data/lib/temporalio/converters/payload_converter/json_plain.rb +44 -0
  90. data/lib/temporalio/converters/payload_converter/json_protobuf.rb +41 -0
  91. data/lib/temporalio/converters/payload_converter.rb +73 -0
  92. data/lib/temporalio/converters.rb +9 -0
  93. data/lib/temporalio/error/failure.rb +119 -94
  94. data/lib/temporalio/error.rb +147 -0
  95. data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +34 -0
  96. data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +31 -0
  97. data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +33 -0
  98. data/lib/temporalio/internal/bridge/api/common/common.rb +26 -0
  99. data/lib/temporalio/internal/bridge/api/core_interface.rb +36 -0
  100. data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
  101. data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +52 -0
  102. data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +54 -0
  103. data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +30 -0
  104. data/lib/temporalio/internal/bridge/api.rb +3 -0
  105. data/lib/temporalio/internal/bridge/client.rb +90 -0
  106. data/lib/temporalio/internal/bridge/runtime.rb +53 -0
  107. data/lib/temporalio/internal/bridge/testing.rb +46 -0
  108. data/lib/temporalio/internal/bridge/worker.rb +83 -0
  109. data/lib/temporalio/internal/bridge.rb +36 -0
  110. data/lib/temporalio/internal/client/implementation.rb +525 -0
  111. data/lib/temporalio/internal/proto_utils.rb +54 -0
  112. data/lib/temporalio/internal/worker/activity_worker.rb +345 -0
  113. data/lib/temporalio/internal/worker/multi_runner.rb +169 -0
  114. data/lib/temporalio/internal.rb +7 -0
  115. data/lib/temporalio/retry_policy.rb +39 -80
  116. data/lib/temporalio/runtime.rb +259 -13
  117. data/lib/temporalio/scoped_logger.rb +96 -0
  118. data/lib/temporalio/search_attributes.rb +300 -0
  119. data/lib/temporalio/testing/activity_environment.rb +132 -0
  120. data/lib/temporalio/testing/workflow_environment.rb +113 -88
  121. data/lib/temporalio/testing.rb +4 -169
  122. data/lib/temporalio/version.rb +3 -1
  123. data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
  124. data/lib/temporalio/worker/activity_executor/thread_pool.rb +254 -0
  125. data/lib/temporalio/worker/activity_executor.rb +55 -0
  126. data/lib/temporalio/worker/interceptor.rb +88 -0
  127. data/lib/temporalio/worker/tuner.rb +151 -0
  128. data/lib/temporalio/worker.rb +385 -163
  129. data/lib/temporalio/workflow_history.rb +22 -0
  130. data/lib/temporalio.rb +2 -7
  131. data/temporalio.gemspec +20 -38
  132. metadata +131 -596
  133. data/bridge/Cargo.lock +0 -2997
  134. data/bridge/Cargo.toml +0 -29
  135. data/bridge/sdk-core/ARCHITECTURE.md +0 -76
  136. data/bridge/sdk-core/Cargo.toml +0 -2
  137. data/bridge/sdk-core/LICENSE.txt +0 -23
  138. data/bridge/sdk-core/README.md +0 -117
  139. data/bridge/sdk-core/arch_docs/diagrams/README.md +0 -10
  140. data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +0 -40
  141. data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
  142. data/bridge/sdk-core/arch_docs/sticky_queues.md +0 -51
  143. data/bridge/sdk-core/client/Cargo.toml +0 -40
  144. data/bridge/sdk-core/client/LICENSE.txt +0 -23
  145. data/bridge/sdk-core/client/src/lib.rs +0 -1462
  146. data/bridge/sdk-core/client/src/metrics.rs +0 -174
  147. data/bridge/sdk-core/client/src/raw.rs +0 -932
  148. data/bridge/sdk-core/client/src/retry.rs +0 -763
  149. data/bridge/sdk-core/client/src/workflow_handle/mod.rs +0 -185
  150. data/bridge/sdk-core/core/Cargo.toml +0 -129
  151. data/bridge/sdk-core/core/LICENSE.txt +0 -23
  152. data/bridge/sdk-core/core/benches/workflow_replay.rs +0 -76
  153. data/bridge/sdk-core/core/src/abstractions.rs +0 -355
  154. data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +0 -1049
  155. data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +0 -221
  156. data/bridge/sdk-core/core/src/core_tests/determinism.rs +0 -270
  157. data/bridge/sdk-core/core/src/core_tests/local_activities.rs +0 -1046
  158. data/bridge/sdk-core/core/src/core_tests/mod.rs +0 -100
  159. data/bridge/sdk-core/core/src/core_tests/queries.rs +0 -893
  160. data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +0 -65
  161. data/bridge/sdk-core/core/src/core_tests/workers.rs +0 -257
  162. data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +0 -124
  163. data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +0 -2433
  164. data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +0 -609
  165. data/bridge/sdk-core/core/src/internal_flags.rs +0 -136
  166. data/bridge/sdk-core/core/src/lib.rs +0 -289
  167. data/bridge/sdk-core/core/src/pollers/mod.rs +0 -54
  168. data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +0 -297
  169. data/bridge/sdk-core/core/src/protosext/mod.rs +0 -428
  170. data/bridge/sdk-core/core/src/replay/mod.rs +0 -215
  171. data/bridge/sdk-core/core/src/retry_logic.rs +0 -202
  172. data/bridge/sdk-core/core/src/telemetry/log_export.rs +0 -190
  173. data/bridge/sdk-core/core/src/telemetry/metrics.rs +0 -462
  174. data/bridge/sdk-core/core/src/telemetry/mod.rs +0 -423
  175. data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +0 -83
  176. data/bridge/sdk-core/core/src/test_help/mod.rs +0 -939
  177. data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +0 -536
  178. data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -89
  179. data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +0 -1278
  180. data/bridge/sdk-core/core/src/worker/activities.rs +0 -557
  181. data/bridge/sdk-core/core/src/worker/client/mocks.rs +0 -107
  182. data/bridge/sdk-core/core/src/worker/client.rs +0 -389
  183. data/bridge/sdk-core/core/src/worker/mod.rs +0 -677
  184. data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +0 -35
  185. data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +0 -99
  186. data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +0 -1111
  187. data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +0 -964
  188. data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -294
  189. data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -168
  190. data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +0 -918
  191. data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -137
  192. data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -158
  193. data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -130
  194. data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -1525
  195. data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -324
  196. data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -179
  197. data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -659
  198. data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -439
  199. data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +0 -435
  200. data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +0 -175
  201. data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +0 -249
  202. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +0 -85
  203. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +0 -1280
  204. data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +0 -269
  205. data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +0 -213
  206. data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +0 -1305
  207. data/bridge/sdk-core/core/src/worker/workflow/mod.rs +0 -1276
  208. data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +0 -128
  209. data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +0 -125
  210. data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +0 -85
  211. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
  212. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
  213. data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +0 -715
  214. data/bridge/sdk-core/core-api/Cargo.toml +0 -33
  215. data/bridge/sdk-core/core-api/LICENSE.txt +0 -23
  216. data/bridge/sdk-core/core-api/src/errors.rs +0 -62
  217. data/bridge/sdk-core/core-api/src/lib.rs +0 -113
  218. data/bridge/sdk-core/core-api/src/telemetry.rs +0 -141
  219. data/bridge/sdk-core/core-api/src/worker.rs +0 -161
  220. data/bridge/sdk-core/etc/deps.svg +0 -162
  221. data/bridge/sdk-core/etc/dynamic-config.yaml +0 -2
  222. data/bridge/sdk-core/etc/otel-collector-config.yaml +0 -36
  223. data/bridge/sdk-core/etc/prometheus.yaml +0 -6
  224. data/bridge/sdk-core/etc/regen-depgraph.sh +0 -5
  225. data/bridge/sdk-core/fsm/Cargo.toml +0 -18
  226. data/bridge/sdk-core/fsm/LICENSE.txt +0 -23
  227. data/bridge/sdk-core/fsm/README.md +0 -3
  228. data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
  229. data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +0 -23
  230. data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +0 -650
  231. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
  232. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +0 -18
  233. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
  234. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +0 -41
  235. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +0 -14
  236. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +0 -11
  237. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +0 -32
  238. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +0 -31
  239. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +0 -46
  240. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +0 -29
  241. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -12
  242. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +0 -32
  243. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +0 -18
  244. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
  245. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +0 -11
  246. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
  247. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +0 -11
  248. data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
  249. data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
  250. data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -23
  251. data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +0 -254
  252. data/bridge/sdk-core/fsm/src/lib.rs +0 -2
  253. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
  254. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
  255. data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
  256. data/bridge/sdk-core/histories/fail_wf_task.bin +0 -0
  257. data/bridge/sdk-core/histories/timer_workflow_history.bin +0 -0
  258. data/bridge/sdk-core/integ-with-otel.sh +0 -7
  259. data/bridge/sdk-core/protos/api_upstream/README.md +0 -9
  260. data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +0 -40
  261. data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -9
  262. data/bridge/sdk-core/protos/api_upstream/build/go.mod +0 -7
  263. data/bridge/sdk-core/protos/api_upstream/build/go.sum +0 -5
  264. data/bridge/sdk-core/protos/api_upstream/build/tools.go +0 -29
  265. data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +0 -141
  266. data/bridge/sdk-core/protos/api_upstream/go.mod +0 -6
  267. data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -89
  268. data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +0 -248
  269. data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +0 -123
  270. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -47
  271. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -52
  272. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -56
  273. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -170
  274. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -123
  275. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -51
  276. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -50
  277. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -41
  278. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -60
  279. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -59
  280. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -56
  281. data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -122
  282. data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -108
  283. data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -114
  284. data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -56
  285. data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +0 -787
  286. data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -99
  287. data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -124
  288. data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -80
  289. data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -57
  290. data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +0 -61
  291. data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -55
  292. data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -379
  293. data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -63
  294. data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -108
  295. data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +0 -111
  296. data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +0 -59
  297. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -146
  298. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +0 -1199
  299. data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +0 -415
  300. data/bridge/sdk-core/protos/grpc/health/v1/health.proto +0 -63
  301. data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -79
  302. data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -80
  303. data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -78
  304. data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +0 -16
  305. data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +0 -31
  306. data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -31
  307. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +0 -270
  308. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -305
  309. data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -35
  310. data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +0 -38
  311. data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +0 -13
  312. data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +0 -141
  313. data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -63
  314. data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -90
  315. data/bridge/sdk-core/rustfmt.toml +0 -1
  316. data/bridge/sdk-core/sdk/Cargo.toml +0 -48
  317. data/bridge/sdk-core/sdk/LICENSE.txt +0 -23
  318. data/bridge/sdk-core/sdk/src/activity_context.rs +0 -230
  319. data/bridge/sdk-core/sdk/src/app_data.rs +0 -37
  320. data/bridge/sdk-core/sdk/src/interceptors.rs +0 -50
  321. data/bridge/sdk-core/sdk/src/lib.rs +0 -861
  322. data/bridge/sdk-core/sdk/src/payload_converter.rs +0 -11
  323. data/bridge/sdk-core/sdk/src/workflow_context/options.rs +0 -295
  324. data/bridge/sdk-core/sdk/src/workflow_context.rs +0 -694
  325. data/bridge/sdk-core/sdk/src/workflow_future.rs +0 -500
  326. data/bridge/sdk-core/sdk-core-protos/Cargo.toml +0 -33
  327. data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +0 -23
  328. data/bridge/sdk-core/sdk-core-protos/build.rs +0 -142
  329. data/bridge/sdk-core/sdk-core-protos/src/constants.rs +0 -7
  330. data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +0 -557
  331. data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +0 -234
  332. data/bridge/sdk-core/sdk-core-protos/src/lib.rs +0 -2088
  333. data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +0 -48
  334. data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +0 -14
  335. data/bridge/sdk-core/test-utils/Cargo.toml +0 -38
  336. data/bridge/sdk-core/test-utils/src/canned_histories.rs +0 -1389
  337. data/bridge/sdk-core/test-utils/src/histfetch.rs +0 -28
  338. data/bridge/sdk-core/test-utils/src/lib.rs +0 -709
  339. data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
  340. data/bridge/sdk-core/test-utils/src/workflows.rs +0 -29
  341. data/bridge/sdk-core/tests/fuzzy_workflow.rs +0 -130
  342. data/bridge/sdk-core/tests/heavy_tests.rs +0 -265
  343. data/bridge/sdk-core/tests/integ_tests/client_tests.rs +0 -36
  344. data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +0 -150
  345. data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +0 -223
  346. data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +0 -239
  347. data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -90
  348. data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +0 -314
  349. data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +0 -151
  350. data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +0 -902
  351. data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
  352. data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -60
  353. data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -51
  354. data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -51
  355. data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -64
  356. data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -47
  357. data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -669
  358. data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -54
  359. data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -92
  360. data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +0 -228
  361. data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +0 -94
  362. data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -171
  363. data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +0 -85
  364. data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -120
  365. data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +0 -77
  366. data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +0 -596
  367. data/bridge/sdk-core/tests/main.rs +0 -103
  368. data/bridge/sdk-core/tests/runner.rs +0 -132
  369. data/bridge/sdk-core/tests/wf_input_replay.rs +0 -32
  370. data/bridge/src/connection.rs +0 -202
  371. data/bridge/src/lib.rs +0 -494
  372. data/bridge/src/runtime.rs +0 -54
  373. data/bridge/src/test_server.rs +0 -153
  374. data/bridge/src/worker.rs +0 -197
  375. data/ext/Rakefile +0 -9
  376. data/lib/gen/dependencies/gogoproto/gogo_pb.rb +0 -14
  377. data/lib/gen/temporal/api/batch/v1/message_pb.rb +0 -50
  378. data/lib/gen/temporal/api/command/v1/message_pb.rb +0 -160
  379. data/lib/gen/temporal/api/common/v1/message_pb.rb +0 -73
  380. data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +0 -33
  381. data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +0 -37
  382. data/lib/gen/temporal/api/enums/v1/common_pb.rb +0 -42
  383. data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +0 -68
  384. data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +0 -79
  385. data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +0 -37
  386. data/lib/gen/temporal/api/enums/v1/query_pb.rb +0 -31
  387. data/lib/gen/temporal/api/enums/v1/reset_pb.rb +0 -24
  388. data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +0 -28
  389. data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +0 -30
  390. data/lib/gen/temporal/api/enums/v1/update_pb.rb +0 -25
  391. data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +0 -89
  392. data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +0 -84
  393. data/lib/gen/temporal/api/failure/v1/message_pb.rb +0 -83
  394. data/lib/gen/temporal/api/filter/v1/message_pb.rb +0 -40
  395. data/lib/gen/temporal/api/history/v1/message_pb.rb +0 -498
  396. data/lib/gen/temporal/api/namespace/v1/message_pb.rb +0 -64
  397. data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +0 -88
  398. data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +0 -20
  399. data/lib/gen/temporal/api/protocol/v1/message_pb.rb +0 -30
  400. data/lib/gen/temporal/api/query/v1/message_pb.rb +0 -38
  401. data/lib/gen/temporal/api/replication/v1/message_pb.rb +0 -37
  402. data/lib/gen/temporal/api/schedule/v1/message_pb.rb +0 -149
  403. data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +0 -23
  404. data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +0 -73
  405. data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +0 -49
  406. data/lib/gen/temporal/api/testservice/v1/service_pb.rb +0 -21
  407. data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -72
  408. data/lib/gen/temporal/api/version/v1/message_pb.rb +0 -41
  409. data/lib/gen/temporal/api/workflow/v1/message_pb.rb +0 -111
  410. data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +0 -798
  411. data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +0 -20
  412. data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +0 -62
  413. data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +0 -61
  414. data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +0 -61
  415. data/lib/gen/temporal/sdk/core/common/common_pb.rb +0 -26
  416. data/lib/gen/temporal/sdk/core/core_interface_pb.rb +0 -40
  417. data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +0 -31
  418. data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +0 -171
  419. data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +0 -200
  420. data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +0 -41
  421. data/lib/temporalio/bridge/connect_options.rb +0 -15
  422. data/lib/temporalio/bridge/error.rb +0 -8
  423. data/lib/temporalio/bridge/retry_config.rb +0 -24
  424. data/lib/temporalio/bridge/tls_options.rb +0 -19
  425. data/lib/temporalio/bridge.rb +0 -14
  426. data/lib/temporalio/client/implementation.rb +0 -340
  427. data/lib/temporalio/connection/retry_config.rb +0 -44
  428. data/lib/temporalio/connection/service.rb +0 -20
  429. data/lib/temporalio/connection/test_service.rb +0 -92
  430. data/lib/temporalio/connection/tls_options.rb +0 -51
  431. data/lib/temporalio/connection/workflow_service.rb +0 -731
  432. data/lib/temporalio/connection.rb +0 -86
  433. data/lib/temporalio/data_converter.rb +0 -191
  434. data/lib/temporalio/error/workflow_failure.rb +0 -19
  435. data/lib/temporalio/errors.rb +0 -40
  436. data/lib/temporalio/failure_converter/base.rb +0 -26
  437. data/lib/temporalio/failure_converter/basic.rb +0 -319
  438. data/lib/temporalio/failure_converter.rb +0 -7
  439. data/lib/temporalio/interceptor/activity_inbound.rb +0 -22
  440. data/lib/temporalio/interceptor/activity_outbound.rb +0 -24
  441. data/lib/temporalio/interceptor/chain.rb +0 -28
  442. data/lib/temporalio/interceptor/client.rb +0 -127
  443. data/lib/temporalio/interceptor.rb +0 -22
  444. data/lib/temporalio/payload_codec/base.rb +0 -32
  445. data/lib/temporalio/payload_converter/base.rb +0 -24
  446. data/lib/temporalio/payload_converter/bytes.rb +0 -27
  447. data/lib/temporalio/payload_converter/composite.rb +0 -49
  448. data/lib/temporalio/payload_converter/encoding_base.rb +0 -35
  449. data/lib/temporalio/payload_converter/json.rb +0 -26
  450. data/lib/temporalio/payload_converter/nil.rb +0 -26
  451. data/lib/temporalio/payload_converter.rb +0 -14
  452. data/lib/temporalio/retry_state.rb +0 -35
  453. data/lib/temporalio/testing/time_skipping_handle.rb +0 -32
  454. data/lib/temporalio/testing/time_skipping_interceptor.rb +0 -23
  455. data/lib/temporalio/timeout_type.rb +0 -29
  456. data/lib/temporalio/worker/activity_runner.rb +0 -114
  457. data/lib/temporalio/worker/activity_worker.rb +0 -164
  458. data/lib/temporalio/worker/reactor.rb +0 -46
  459. data/lib/temporalio/worker/runner.rb +0 -63
  460. data/lib/temporalio/worker/sync_worker.rb +0 -124
  461. data/lib/temporalio/worker/thread_pool_executor.rb +0 -51
  462. data/lib/temporalio/workflow/async.rb +0 -46
  463. data/lib/temporalio/workflow/execution_info.rb +0 -54
  464. data/lib/temporalio/workflow/execution_status.rb +0 -36
  465. data/lib/temporalio/workflow/future.rb +0 -138
  466. data/lib/temporalio/workflow/id_reuse_policy.rb +0 -36
  467. data/lib/temporalio/workflow/info.rb +0 -76
  468. data/lib/temporalio/workflow/query_reject_condition.rb +0 -33
  469. data/lib/thermite_patch.rb +0 -23
data/README.md CHANGED
@@ -1,303 +1,563 @@
1
- # Temporal Ruby SDK
1
+ ![Temporal Ruby SDK](https://raw.githubusercontent.com/temporalio/assets/main/files/w/ruby.png)
2
2
 
3
- [![CI status](https://github.com/temporalio/sdk-ruby/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/temporalio/sdk-ruby/actions/workflows/ci.yml?query=branch%3Amain)
4
- [![Build](https://github.com/temporalio/sdk-ruby/actions/workflows/build-native-ext.yml/badge.svg)](https://github.com/temporalio/sdk-ruby/actions/workflows/build-native-ext.yml?query=branch%3Amain+event%3Arelease)
5
- [![Gem Version](https://badge.fury.io/rb/temporalio.svg)](https://rubygems.org/gems/temporalio)
3
+ ![Ruby 3.1 | 3.2 | 3.3](https://img.shields.io/badge/ruby-3.1%20%7C%203.2%20%7C%203.3-blue.svg?style=for-the-badge)
4
+ [![MIT](https://img.shields.io/github/license/temporalio/sdk-ruby.svg?style=for-the-badge)](LICENSE)
5
+ [![Gem](https://img.shields.io/gem/v/temporalio?style=for-the-badge)](https://rubygems.org/gems/temporalio)
6
6
 
7
- [Temporal](https://temporal.io/) is a distributed, scalable, durable, and highly available
8
- orchestration engine used to execute asynchronous long-running business logic in a scalable and
9
- resilient way.
7
+ [Temporal](https://temporal.io/) is a distributed, scalable, durable, and highly available orchestration engine used to
8
+ execute asynchronous, long-running business logic in a scalable and resilient way.
10
9
 
11
- "Temporal Ruby SDK" is the framework for authoring workflows and activities using the Ruby
12
- programming language.
10
+ **Temporal Ruby SDK** is the framework for authoring workflows and activities using the Ruby programming language.
13
11
 
14
- ⚠️ UNDER DEVELOPMENT
12
+ Also see:
15
13
 
16
- The Ruby SDK is under development. There are no compatibility guarantees at this time.
14
+ * [Ruby Samples](https://github.com/temporalio/samples-ruby)
15
+ * [API Documentation](https://rubydoc.info/gems/temporalio)
17
16
 
18
- At this point the SDK only supports the **Temporal Client** capabilities:
17
+ ⚠️ UNDER ACTIVE DEVELOPMENT
19
18
 
20
- - Starting a workflow (defined in any other SDK)
21
- - Interacting with a workflow (cancelling, querying, signalling, etc)
22
- - Interceptor and Data Conversion support
23
- - gRPC access to Temporal Server
19
+ This SDK is under active development and has not released a stable version yet. APIs may change in incompatible ways
20
+ until the SDK is marked stable. The SDK has undergone a refresh from a previous unstable version. The last tag before
21
+ this refresh is [v0.1.1](https://github.com/temporalio/sdk-ruby/tree/v0.1.1). Please reference that tag for the
22
+ previous code if needed.
24
23
 
25
- As well as **Activity Worker** capabilities:
24
+ Notably missing from this SDK:
26
25
 
27
- - Definiting activities
28
- - Activity heartbeats/cancellations
29
- - Running activity workers
26
+ * Workflow workers
27
+
28
+ **NOTE: This README is for the current branch and not necessarily what's released on RubyGems.**
29
+
30
+ ---
31
+
32
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
33
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
+ **Contents**
35
+
36
+ - [Quick Start](#quick-start)
37
+ - [Installation](#installation)
38
+ - [Implementing an Activity](#implementing-an-activity)
39
+ - [Running a Workflow](#running-a-workflow)
40
+ - [Usage](#usage)
41
+ - [Client](#client)
42
+ - [Cloud Client Using mTLS](#cloud-client-using-mtls)
43
+ - [Data Conversion](#data-conversion)
44
+ - [ActiveRecord and ActiveModel](#activerecord-and-activemodel)
45
+ - [Workers](#workers)
46
+ - [Workflows](#workflows)
47
+ - [Activities](#activities)
48
+ - [Activity Definition](#activity-definition)
49
+ - [Activity Context](#activity-context)
50
+ - [Activity Heartbeating and Cancellation](#activity-heartbeating-and-cancellation)
51
+ - [Activity Worker Shutdown](#activity-worker-shutdown)
52
+ - [Activity Concurrency and Executors](#activity-concurrency-and-executors)
53
+ - [Activity Testing](#activity-testing)
54
+ - [Platform Support](#platform-support)
55
+ - [Development](#development)
56
+ - [Build](#build)
57
+ - [Build Platform-specific Gem](#build-platform-specific-gem)
58
+ - [Testing](#testing)
59
+ - [Code Formatting and Type Checking](#code-formatting-and-type-checking)
60
+ - [Proto Generation](#proto-generation)
61
+
62
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
30
63
 
31
64
  ## Quick Start
32
65
 
33
66
  ### Installation
34
67
 
35
- Add the [temporalio gem](https://rubygems.org/gems/temporalio) to your Gemfile:
68
+ Can require in a Gemfile like:
36
69
 
37
- ```ruby
70
+ ```
38
71
  gem 'temporalio'
39
72
  ```
40
73
 
41
- The SDK is now ready for use. To build from source, see [Dev Setup](#dev-setup).
74
+ Or via `gem install` like:
42
75
 
43
- **NOTE: This README is for the current branch and not necessarily what's released on RubyGems.**
76
+ ```
77
+ gem install temporalio
78
+ ```
44
79
 
45
- ## Usage
80
+ **NOTE**: Only macOS ARM/x64 and Linux ARM/x64 are supported, and the platform-specific gem chosen is based on when the
81
+ gem/bundle install is performed. A source gem is published but cannot be used directly and will fail to build if tried.
82
+ MinGW-based Windows and Linux MUSL do not have gems. See the [Platform Support](#platform-support) section for more
83
+ information.
46
84
 
47
- ### Client
85
+ **NOTE**: Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and `async` gem) are only
86
+ supported on Ruby versions 3.3 and newer.
87
+
88
+ ### Implementing an Activity
89
+
90
+ Implementing workflows is not yet supported in the Ruby SDK, but implementing activities is.
48
91
 
49
- A client can be created and used to start a workflow like so:
92
+ For example, if you have a `SayHelloWorkflow` workflow in another Temporal language that invokes `SayHello` activity on
93
+ `my-task-queue` in Ruby, you can have the following Ruby script:
50
94
 
51
95
  ```ruby
52
- # Establish a gRPC connection to the server
53
- connection = Temporalio::Connection.new('localhost:7233')
96
+ require 'temporalio/activity'
97
+ require 'temporalio/cancellation'
98
+ require 'temporalio/client'
99
+ require 'temporalio/worker'
54
100
 
55
- # To enable TLS, simply add the `tls:` argument:
56
- # Temporalio::Connection.new(
57
- # 'localhost:7233',
58
- # tls: Temporalio::Connection::TlsOptions.new(client_cert, client_private_key)
59
- # )
101
+ # Implementation of a simple activity
102
+ class SayHelloActivity < Temporalio::Activity
103
+ def execute(name)
104
+ "Hello, #{name}!"
105
+ end
106
+ end
60
107
 
61
- # Initialize a Client with a namespace
62
- client = Temporalio::Client.new(connection, 'my-namespace')
108
+ # Create a client
109
+ client = Temporalio::Client.connect('localhost:7233', 'my-namespace')
63
110
 
64
- # Start a workflow
65
- handle = client.start_workflow('MyWorkflow', 'some input', id: 'my-id', task_queue: 'my-task-queue')
111
+ # Create a worker with the client and activities
112
+ worker = Temporalio::Worker.new(
113
+ client:,
114
+ task_queue: 'my-task-queue',
115
+ # There are various forms an activity can take, see specific section for details.
116
+ activities: [SayHelloActivity]
117
+ )
66
118
 
67
- # Wait for the workflow to finish processing
68
- result = handle.result
69
- puts "Result: #{result}"
119
+ # Run the worker until SIGINT. This can be done in many ways, see specific
120
+ # section for details.
121
+ worker.run(shutdown_signals: ['SIGINT'])
70
122
  ```
71
123
 
72
- Some things to note about the above code:
124
+ Running that will run the worker until Ctrl+C pressed.
73
125
 
74
- - A `Client` does not have an explicit "close"
75
- - All positional arguments after the workflow name are treated as workflow arguments
76
- - The `handle` represents the workflow that was started and can be used for more than just getting
77
- the result
78
- - Clients can have many more options not shown here (e.g. data converters and interceptors)
126
+ ### Running a Workflow
79
127
 
80
- ### Data Conversion
128
+ Assuming that `SayHelloWorkflow` just calls this activity, it can be run like so:
81
129
 
82
- Data converters are used to convert raw Temporal payloads to/from actual Ruby types. These consist
83
- of 3 distinct types of converters:
84
-
85
- - **Payload Converters** to convert Ruby values to/from serialized bytes
86
- - **Payload Codecs** to convert bytes to bytes (e.g. for compression or encryption)
87
- - **Failure Converters** to convert exceptions to/from serialized failures
130
+ ```ruby
131
+ require 'temporalio/client'
132
+
133
+ # Create a client
134
+ client = Temporalio::Client.connect('localhost:7233', 'my-namespace')
135
+
136
+ # Run workflow
137
+ result = client.execute_workflow(
138
+ 'SayHelloWorkflow',
139
+ 'Temporal',
140
+ id: 'my-workflow-id',
141
+ task_queue: 'my-task-queue'
142
+ )
143
+ puts "Result: #{result}"
144
+ ```
88
145
 
89
- The default data converter supports converting multiple types including:
146
+ This will output:
90
147
 
91
- - `nil`
92
- - bytes (`String` with `Encoding::ASCII_8BIT`)
93
- - Anything that [JSON.generate](https://ruby-doc.org/stdlib-3.0.0/libdoc/json/rdoc/JSON.html#method-i-generate)
94
- supports
148
+ ```
149
+ Result: Hello, Temporal!
150
+ ```
95
151
 
96
- This notably doesn't include any `Date`, `Time`, or `DateTime` objects as they may not work across
97
- different SDKs. A custom payload converter can be implemented to support these.
152
+ ## Usage
98
153
 
99
- ### Workers
154
+ ### Client
100
155
 
101
- Workers host workflows (coming soon) and/or activities. Here's how to run a worker:
156
+ A client can be created and used to start a workflow or otherwise interact with Temporal. For example:
102
157
 
103
158
  ```ruby
104
- require 'temporalio'
105
-
106
- # Establish a gRPC connection to the server
107
- connection = Temporalio::Connection.new('localhost:7233')
159
+ require 'temporalio/client'
108
160
 
109
- # Initialize a new worker with your activities
110
- worker = Temporalio::Worker.new(connection, 'my-namespace', 'my-task-queue', activities: [MyActivity])
161
+ # Create a client
162
+ client = Temporalio::Client.connect('localhost:7233', 'my-namespace')
111
163
 
112
- # Occupy the thread by running the worker
113
- worker.run
164
+ # Start a workflow
165
+ handle = client.start_workflow(
166
+ 'SayHelloWorkflow',
167
+ 'Temporal',
168
+ id: 'my-workflow-id',
169
+ task_queue: 'my-task-queue'
170
+ )
171
+
172
+ # Wait for result
173
+ result = handle.result
174
+ puts "Result: #{result}"
114
175
  ```
115
176
 
116
- Some things to note about the above code:
177
+ Notes about the above code:
117
178
 
118
- - This creates/uses the same connection that is used for initializing a client
119
- - Workers can have many more options not shown here (e.g. data converters and interceptors)
179
+ * Temporal clients are not explicitly closed.
180
+ * To enable TLS, the `tls` option can be set to `true` or a `Temporalio::Client::Connection::TLSOptions` instance.
181
+ * Instead of `start_workflow` + `result` above, `execute_workflow` shortcut can be used if the handle is not needed.
182
+ * The `handle` above is a `Temporalio::Client::WorkflowHandle` which has several other operations that can be performed
183
+ on a workflow. To get a handle to an existing workflow, use `workflow_handle` on the client.
184
+ * Clients are thread safe and are fiber-compatible (but fiber compatibility only supported for Ruby 3.3+ at this time).
120
185
 
121
- In order to have more control over running of a worker you can provide a block of code by the end of
122
- which the worker will shut itself down:
186
+ #### Cloud Client Using mTLS
187
+
188
+ Assuming a client certificate is present at `my-cert.pem` and a client key is present at `my-key.pem`, this is how to
189
+ connect to Temporal Cloud:
123
190
 
124
191
  ```ruby
125
- # Initialize worker_1, worker_2 and worker_3 as in the example above
192
+ require 'temporalio/client'
193
+
194
+ # Create a client
195
+ client = Temporalio::Client.connect(
196
+ 'my-namespace.a1b2c.tmprl.cloud:7233',
197
+ 'my-namespace.a1b2c',
198
+ tls: Temporalio::Client::Connection::TLSOptions.new(
199
+ client_cert: File.read('my-cert.pem'),
200
+ client_private_key: File.read('my-key.pem')
201
+ ))
202
+ ```
126
203
 
127
- # Run the worker for 5 seconds, then shut down
128
- worker_1.run { sleep 5 }
204
+ #### Data Conversion
129
205
 
130
- # Or shut the worker down when a workflow completes (very useful for running specs):
131
- client = Temporalio::Client.new(connection, 'my-namespace')
132
- handle = client.start_workflow('MyWorkflow', 'some input', id: 'my-id', task_queue: 'my-task-queue')
133
- worker_2.run { handle.result }
206
+ Data converters are used to convert raw Temporal payloads to/from actual Ruby types. A custom data converter can be set
207
+ via the `data_converter` keyword argument when creating a client. Data converters are a combination of payload
208
+ converters, payload codecs, and failure converters. Payload converters convert Ruby values to/from serialized bytes.
209
+ Payload codecs convert bytes to bytes (e.g. for compression or encryption). Failure converters convert exceptions
210
+ to/from serialized failures.
134
211
 
135
- # Or wait for some external signal to stop the worker
136
- stop_queue = Queue.new
137
- Signal.trap('USR1') { stop_queue.close }
138
- worker_3.run { stop_queue.pop }
139
- ```
212
+ Data converters are in the `Temporalio::Converters` module. The default data converter uses a default payload converter,
213
+ which supports the following types:
214
+
215
+ * `nil`
216
+ * "bytes" (i.e. `String` with `Encoding::ASCII_8BIT` encoding)
217
+ * `Google::Protobuf::MessageExts` instances
218
+ * [`JSON` module](https://docs.ruby-lang.org/en/master/JSON.html) for everything else
140
219
 
141
- You can also shut down a running worker by calling `Temporalio::Worker#shutdown` from a separate
142
- thread at any time.
220
+ This means that normal Ruby objects will use `JSON.generate` when serializing and `JSON.parse` when deserializing (with
221
+ `create_additions: true` set by default). So a Ruby object will often appear as a hash when deserialized. While
222
+ "JSON Additions" are supported, it is not cross-SDK-language compatible since this is a Ruby-specific construct.
143
223
 
144
- #### Running multiple workers
224
+ The default payload converter is a collection of "encoding payload converters". On serialize, each encoding converter
225
+ will be tried in order until one accepts (default falls through to the JSON one). The encoding converter sets an
226
+ `encoding` metadata value which is used to know which converter to use on deserialize. Custom encoding converters can be
227
+ created, or even the entire payload converter can be replaced with a different implementation.
145
228
 
146
- In order to run multiple workers in the same thread you can use the `Temporalio::Worker.run` method:
229
+ ##### ActiveRecord and ActiveModel
230
+
231
+ By default, `ActiveRecord` and `ActiveModel` objects do not natively support the `JSON` module. A mixin can be created
232
+ to add this support for `ActiveRecord`, for example:
147
233
 
148
234
  ```ruby
149
- # Initialize workers
150
- worker_1 = Temporalio::Worker.new(connection, 'my-namespace-1', 'my-task-queue-1', activities: [MyActivity1, MyActivity2])
151
- worker_2 = Temporalio::Worker.new(connection, 'my-namespace-2', 'my-task-queue-1', activities: [MyActivity3])
152
- worker_3 = Temporalio::Worker.new(connection, 'my-namespace-1', 'my-task-queue-2', activities: [MyActivity4])
235
+ module ActiveRecordJSONSupport
236
+ extend ActiveSupport::Concern
237
+ include ActiveModel::Serializers::JSON
238
+
239
+ included do
240
+ def to_json(*args)
241
+ hash = as_json
242
+ hash[::JSON.create_id] = self.class.name
243
+ hash.to_json(*args)
244
+ end
153
245
 
154
- Temporalio::Worker.run(worker_1, worker_2, worker_3)
246
+ def self.json_create(object)
247
+ object.delete(::JSON.create_id)
248
+ ret = new
249
+ ret.attributes = object
250
+ ret
251
+ end
252
+ end
253
+ end
155
254
  ```
156
255
 
157
- Please note that similar to `Temporalio::Worker#run`, `Temporalio::Worker.run` accepts a block that
158
- behaves the same way — the workers will be shut down when the block finishes.
256
+ Similarly, a mixin for `ActiveModel` that adds `attributes` accessors can leverage this same mixin, for example:
159
257
 
160
- You can also configure your worker to listen on process signals to initiate a shutdown:
258
+ ```ruby
259
+ module ActiveModelJSONSupport
260
+ extend ActiveSupport::Concern
261
+ include ActiveRecordJSONSupport
262
+
263
+ included do
264
+ def attributes=(hash)
265
+ hash.each do |key, value|
266
+ send("#{key}=", value)
267
+ end
268
+ end
269
+
270
+ def attributes
271
+ instance_values
272
+ end
273
+ end
274
+ end
275
+ ```
276
+
277
+ Now `include ActiveRecordJSONSupport` or `include ActiveModelJSONSupport` will make the models work with Ruby `JSON`
278
+ module and therefore Temporal. Of course any other approach to make the models work with the `JSON` module will work as
279
+ well.
280
+
281
+ ### Workers
282
+
283
+ Workers host workflows and/or activities. Workflows cannot yet be written in Ruby, but activities can. Here's how to run
284
+ an activity worker:
161
285
 
162
286
  ```ruby
163
- Temporalio::Worker.run(worker_1, worker_2, worker_3, shutdown_signals: %w[INT TERM])
287
+ require 'temporalio/client'
288
+ require 'temporalio/worker'
289
+ require 'my_module'
290
+
291
+ # Create a client
292
+ client = Temporalio::Client.connect('localhost:7233', 'my-namespace')
293
+
294
+ # Create a worker with the client and activities
295
+ worker = Temporalio::Worker.new(
296
+ client:,
297
+ task_queue: 'my-task-queue',
298
+ # There are various forms an activity can take, see specific section for details.
299
+ activities: [MyModule::MyActivity]
300
+ )
301
+
302
+ # Run the worker until block complete
303
+ worker.run do
304
+ something_that_waits_for_completion
305
+ end
164
306
  ```
165
307
 
166
- #### Worker Shutdown
308
+ Notes about the above code:
309
+
310
+ * A worker uses the same client that is used for other Temporal things.
311
+ * This just shows providing an activity class, but there are other forms, see the "Activities" section for details.
312
+ * The worker `run` method accepts an optional `Temporalio::Cancellation` object that can be used to cancel instead or in
313
+ addition to providing a block that waits for completion.
314
+ * The worker `run` method accepts an `shutdown_signals` array which will trap the signal and start shutdown when
315
+ received.
316
+ * Workers work with threads or fibers (but fiber compatibility only supported for Ruby 3.3+ at this time). Fiber-based
317
+ activities (see "Activities" section) only work if the worker is created within a fiber.
318
+ * The `run` method does not return until the worker is shut down. This means even if shutdown is triggered (e.g. via
319
+ `Cancellation` or block completion), it may not return immediately. Activities not completing may hang worker
320
+ shutdown, see the "Activities" section.
321
+ * Workers can have many more options not shown here (e.g. data converters and interceptors).
322
+ * The `Temporalio::Worker.run_all` class method is available for running multiple workers concurrently.
167
323
 
168
- The `Temporalio::Worker#run` (as well as `Temporalio::Worker#shutdown`) invocation will wait on all
169
- activities to complete, so if a long-running activity does not at least respect cancellation, the
170
- shutdown may never complete.
324
+ ### Workflows
171
325
 
172
- If a worker was initialized with a `graceful_shutdown_timeout` option then a cancellation will be
173
- issued for every running activity after the set timeout. The bahaviour is mostly identical to a
174
- server requested cancellation and should be handled accordingly. More on this in [Heartbeating and
175
- Cancellation](#heartbeating-and-cancellation).
326
+ ⚠️ Workflows cannot yet be implemented Ruby.
176
327
 
177
328
  ### Activities
178
329
 
179
- #### Definition
330
+ #### Activity Definition
180
331
 
181
- Activities are defined by subclassing `Temporalio::Activity` class:
332
+ Activities can be defined in a few different ways. They are usually classes, but manual definitions are supported too.
333
+
334
+ Here is a common activity definition:
182
335
 
183
336
  ```ruby
184
- class SayHelloActivity < Temporalio::Activity
185
- # Optionally specify a custom activity name:
186
- # (The class name `SayHelloActivity` will be used by default)
187
- activity_name 'say-hello'
337
+ class FindUserActivity < Temporalio::Activity
338
+ def execute(user_id)
339
+ User.find(user_id)
340
+ end
341
+ end
342
+ ```
188
343
 
189
- def execute(name)
190
- return "Hello, #{name}!"
344
+ Activities are defined as classes that extend `Temporalio::Activity` and provide an `execute` method. When this activity
345
+ is provided to the worker as a _class_ (e.g. `activities: [FindUserActivity]`), it will be instantiated for
346
+ _every attempt_. Many users may prefer using the same instance across activities, for example:
347
+
348
+ ```ruby
349
+ class FindUserActivity < Temporalio::Activity
350
+ def initialize(db)
351
+ @db = db
352
+ end
353
+
354
+ def execute(user_id)
355
+ @db[:users].first(id: user_id)
191
356
  end
192
357
  end
193
358
  ```
194
359
 
195
- Some things to note about activity definitions:
360
+ When this is provided to a worker as an instance of the activity (e.g. `activities: [FindUserActivity.new(my_db)]`) then
361
+ the same instance is reused for each activity.
362
+
363
+ Some notes about activity definition:
196
364
 
197
- - Long running activities should regularly heartbeat and handle cancellation
198
- - Activities can only have positional arguments. Best practice is to only take a single argument
199
- that is an object/dataclass of fields that can be added to as needed.
365
+ * Temporal activities are identified by their name (or sometimes referred to as "activity type"). This defaults to the
366
+ unqualified class name of the activity, but can be customized by calling the `activity_name` class method.
367
+ * Long running activities should heartbeat regularly, see "Activity Heartbeating and Cancellation" later.
368
+ * By default every activity attempt is executed in a thread on a thread pool, but fibers are also supported. See
369
+ "Activity Concurrency and Executors" section later for more details.
370
+ * Technically an activity definition can be created manually via `Temporalio::Activity::Definition.new` that accepts a
371
+ proc or a block, but the class form is recommended.
200
372
 
201
373
  #### Activity Context
202
374
 
203
- Activity classes have access to `Temporalio::Activity::Context` via the `activity` method. Which
204
- itself provides access to useful methods, specifically:
375
+ When running in an activity, the `Temporalio::Activity::Context` is available via
376
+ `Temporalio::Activity::Context.current` which is backed by a thread/fiber local. In addition to other more advanced
377
+ things, this context provides:
205
378
 
206
- - `info` - Returns the immutable info of the currently running activity
207
- - `heartbeat(*details)` - Record a heartbeat
208
- - `cancelled?` - Whether a cancellation has been requested on this activity
209
- - `shield` - Prevent cancel exception from being thrown during the provided block of code
379
+ * `info` - Information about the running activity.
380
+ * `heartbeat` - Method to call to issue an activity heartbeat (see "Activity Heartbeating and Cancellation" later).
381
+ * `cancellation` - Instance of `Temporalio::Cancellation` canceled when an activity is canceled (see
382
+ "Activity Heartbeating and Cancellation" later).
383
+ * `worker_shutdown_cancellation` - Instance of `Temporalio::Cancellation` canceled when worker is shutting down (see
384
+ "Activity Worker Shutdown" later).
385
+ * `logger` - Logger that automatically appends a hash with some activity info to every message.
210
386
 
211
- ##### Heartbeating and Cancellation
387
+ #### Activity Heartbeating and Cancellation
212
388
 
213
- In order for a non-local activity to be notified of cancellation requests, it must call
214
- `activity.heartbeat`. It is strongly recommended that all but the fastest executing activities call
215
- this method regularly.
389
+ In order for a non-local activity to be notified of server-side cancellation requests, it must regularly invoke
390
+ `heartbeat` on the `Temporalio::Activity::Context` instance (available via `Temporalio::Activity::Context.current`). It
391
+ is strongly recommended that all but the fastest executing activities call this function regularly.
216
392
 
217
- In addition to obtaining cancellation information, heartbeats also support detail data that is
218
- persisted on the server for retrieval during activity retry. If an activity calls
219
- `activity.heartbeat(123, 456)` and then fails and is retried, `activity.info.heartbeat_details` will
220
- return an array containing `123` and `456` on the next run.
393
+ In addition to obtaining cancellation information, heartbeats also support detail data that is persisted on the server
394
+ for retrieval during activity retry. If an activity calls `heartbeat(123)` and then fails and is retried,
395
+ `Temporalio::Activity::Context.current.info.heartbeat_details.first` will be `123`.
221
396
 
222
- A cancellation is implemented using the `Thread#raise` method, which will raise a
223
- `Temporalio::Error::ActivityCancelled` during the execution of an activity. This means that your code
224
- might get interrupted at any point and never complete. In order to protect critical parts of your
225
- activities wrap them in `activity.shield`:
397
+ An activity can be canceled for multiple reasons, some server-side and some worker side. Server side cancellation
398
+ reasons include workflow canceling the activity, workflow completing, or activity timing out. On the worker side, the
399
+ activity can be canceled on worker shutdown (see next section). By default cancellation is relayed two ways - by marking
400
+ the `cancellation` on `Temporalio::Activity::Context` as canceled, and by issuing a `Thread.raise` or `Fiber.raise` with
401
+ the `Temporalio::Error::CanceledError`.
226
402
 
227
- ```ruby
228
- class ActivityWithCriticalLogic < Temporalio::Activity
229
- def execute
230
- activity.shield do
231
- run_business_critical_logic_1
232
- end
403
+ The `raise`-by-default approach was chosen because it is dangerous to the health of the system and the continued use of
404
+ worker slots to require activities opt-in to checking for cancellation by default. But if this behavior is not wanted,
405
+ `activity_cancel_raise false` class method can be called at the top of the activity which will disable the `raise`
406
+ behavior and just set the `cancellation` as canceled.
233
407
 
234
- run_non_critical_logic
408
+ If needing to shield work from being canceled, the `shield` call on the `Temporalio::Cancellation` object can be used
409
+ with a block for the code to be shielded. The cancellation will not take effect on the cancellation object nor the raise
410
+ call while the work is shielded (regardless of nested depth). Once the shielding is complete, the cancellation will take
411
+ effect, including `Thread.raise`/`Fiber.raise` if that remains enabled.
235
412
 
236
- activity.shield do
237
- run_business_critical_logic_2
238
- end
239
- end
240
- end
241
- ```
413
+ #### Activity Worker Shutdown
242
414
 
243
- This will ensure that a cancellation request received while inside the `activity.shield` block will
244
- not raise an exception until that block finishes.
415
+ An activity can react to a worker shutdown specifically and also a normal cancellation will be sent. A worker will not
416
+ complete its shutdown while an activity is in progress.
245
417
 
246
- In case the entire activity is considered critical, you can mark it as `shielded!` and ignore
247
- cancellation requests altogether:
418
+ Upon worker shutdown, the `worker_shutdown_cancellation` cancellation on `Temporalio::Activity::Context` will be
419
+ canceled. Then the worker will wait a for a grace period set by the `graceful_shutdown_period` worker option (default 0)
420
+ before issuing actual cancellation to all still-running activities.
248
421
 
249
- ```ruby
250
- class CriticalActivity < Temporalio::Activity
251
- shielded!
422
+ Worker shutdown will then wait on all activities to complete. If a long-running activity does not respect cancellation,
423
+ the shutdown may never complete.
252
424
 
253
- def execute
254
- ...
255
- end
256
- end
257
- ```
425
+ #### Activity Concurrency and Executors
258
426
 
259
- For any long-running activity using this approach it is recommended to periodically check
260
- `activity.cancelled?` flag and respond accordingly.
427
+ By default, activities run in the "thread pool executor" (i.e. `Temporalio::Worker::ActivityExecutor::ThreadPool`). This
428
+ default is shared across all workers and is a naive thread pool that continually makes threads as needed when none are
429
+ idle/available to handle incoming work. If a thread sits idle long enough, it will be killed.
261
430
 
262
- Please note that your activities can also get cancelled during a worker shutdown process ([if
263
- configured accordingly](#worker-shutdown)).
431
+ The maximum number of concurrent activities a worker will run at a time is configured via its `tuner` option. The
432
+ default is `Temporalio::Worker::Tuner.create_fixed` which defaults to 100 activities at a time for that worker. When
433
+ this value is reached, the worker will stop asking for work from the server until there are slots available again.
264
434
 
265
- ## Dev Setup
435
+ In addition to the thread pool executor, there is also a fiber executor in the default executor set. To use fibers, call
436
+ `activity_executor :fiber` class method at the top of the activity class (the default of this value is `:default` which
437
+ is the thread pool executor). Activities can only choose the fiber executor if the worker has been created and run in a
438
+ fiber, but thread pool executor is always available. Currently due to
439
+ [an issue](https://github.com/temporalio/sdk-ruby/issues/162), workers can only run in a fiber on Ruby versions 3.3 and
440
+ newer.
266
441
 
267
- Once you've forked/cloned the repository you want to make sure all the submodules are fetched as
268
- well. You can do that using:
442
+ Technically the executor can be customized. The `activity_executors` worker option accepts a hash with the key as the
443
+ symbol and the value as a `Temporalio::Worker::ActivityExecutor` implementation. Users should usually not need to
444
+ customize this. If general code is needed to run around activities, users should use interceptors instead.
269
445
 
270
- ```sh
271
- > git submodule update --recursive
272
- ```
446
+ #### Activity Testing
273
447
 
274
- From there you should be able to install all the Ruby gems using:
448
+ Unit testing an activity can be done via the `Temporalio::Testing::ActivityEnvironment` class. Simply instantiate the
449
+ class, then invoke `run` with the activity to test and the arguments to give. The result will be the activity result or
450
+ it will raise the error raised in the activity.
275
451
 
276
- ```sh
277
- > bundle install
278
- ```
452
+ The constructor of the environment has multiple keyword arguments that can be set to affect the activity context for the
453
+ activity.
279
454
 
280
- In order to compile the Rust Bridge you need to have `rust`, `cargo` and `rustup` installed. You
281
- will also need to install the `rustfmt` component:
455
+ ### Platform Support
282
456
 
283
- ```sh
284
- > rustup component add rustfmt
285
- ```
457
+ This SDK is backed by a Ruby C extension written in Rust leveraging the
458
+ [Temporal Rust Core](https://github.com/temporalio/sdk-core). Gems are currently published for the following platforms:
286
459
 
287
- Now you should be able to compile a dev build of the Bridge:
460
+ * `aarch64-linux`
461
+ * `x86_64-linux`
462
+ * `arm64-darwin`
463
+ * `x86_64-darwin`
288
464
 
289
- ```sh
290
- > bundle exec rake bridge:build
291
- ```
465
+ This means Linux and macOS for ARM and x64 have published gems. Currently, a gem is not published for
466
+ `aarch64-linux-musl` so Alpine Linux users may need to build from scratch or use a libc-based distro.
292
467
 
293
- You can then run all the specs against a dev build using:
468
+ Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/172) with Windows and multi-threaded Rust, MinGW-based
469
+ Windows (i.e. `x64-mingw-ucrt`) is not supported. But WSL is supported using the normal Linux gem.
294
470
 
295
- ```sh
296
- > bundle exec rspec
297
- ```
471
+ At this time a pure source gem is published for documentation reasons, but it cannot be built and will fail if tried.
472
+ Building from source requires many files across submodules and requires Rust to be installed. See the [Build](#build)
473
+ section for how to build a the repository.
298
474
 
299
- And open an IRB session using:
475
+ The SDK works on Ruby 3.1+, but due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and
476
+ `async` gem) are only supported on Ruby versions 3.3 and newer.
300
477
 
301
- ```sh
302
- > bundle console
303
- ```
478
+ ## Development
479
+
480
+ ### Build
481
+
482
+ Prerequisites:
483
+
484
+ * [Ruby](https://www.ruby-lang.org/) >= 3.1 (i.e. `ruby` and `bundle` on the `PATH`)
485
+ * [Rust](https://www.rust-lang.org/) latest stable (i.e. `cargo` on the `PATH`)
486
+ * This repository, cloned recursively
487
+ * Change to the `temporalio/` directory
488
+
489
+ First, install dependencies:
490
+
491
+ bundle install
492
+
493
+ To build shared library for development use:
494
+
495
+ bundle exec rake compile
496
+
497
+ **NOTE**: This will make the current directory usable for the current Ruby version by putting the shared library
498
+ `lib/temporalio/internal/bridge/temporalio_bridge.<ext>` in the proper place. But this development shared library may
499
+ not work for other Ruby versions or other OS/arch combinations. For that, see "Build Platform-specific Gem" below.
500
+
501
+ **NOTE**: This is not `compile:dev` because debug-mode in Rust has
502
+ [an issue](https://github.com/rust-lang/rust/issues/34283) that causes runtime stack size problems.
503
+
504
+ To lint, build, and test:
505
+
506
+ bundle exec rake
507
+
508
+ #### Build Platform-specific Gem
509
+
510
+ The standard `bundle exec rake build` will produce a gem in the `pkg` directory, but that gem will not be usable because
511
+ the shared library is not present (neither the Rust code nor the compiled form). To create a platform-specific gem that
512
+ can be used, `rb-sys-dock` must be run. See the
513
+ [Cross-Compilation documentation](https://oxidize-rb.github.io/rb-sys/tutorial/publishing/cross-compilation.html) in the
514
+ `rb-sys` repository. For example, running:
515
+
516
+ bundle exec rb-sys-dock --platform x86_64-linux --ruby-versions 3.2,3.3 --build
517
+
518
+ Will create a `pkg/temporalio-<version>-x86_64-linux.gem` file that can be used in x64 Linux environments on both Ruby
519
+ 3.2 and Ruby 3.3 because it contains the shared libraries. For this specific example, the shared libraries are inside
520
+ the gem at `lib/temporalio/internal/bridge/3.2/temporalio_bridge.so` and
521
+ `lib/temporalio/internal/bridge/3.3/temporalio_bridge.so`.
522
+
523
+ ### Testing
524
+
525
+ This project uses `minitest`. To test:
526
+
527
+ bundle exec rake test
528
+
529
+ Can add options via `TESTOPTS`. E.g. single test:
530
+
531
+ bundle exec rake test TESTOPTS="--name=test_some_method"
532
+
533
+ E.g. all starting with prefix:
534
+
535
+ bundle exec rake test TESTOPTS="--name=/^test_some_method_prefix/"
536
+
537
+ E.g. all for a class:
538
+
539
+ bundle exec rake test TESTOPTS="--name=/SomeClassName/"
540
+
541
+ E.g. show all test names while executing:
542
+
543
+ bundle exec rake test TESTOPTS="--verbose"
544
+
545
+ ### Code Formatting and Type Checking
546
+
547
+ This project uses `rubocop`:
548
+
549
+ bundle exec rake rubocop:autocorrect
550
+
551
+ This project uses `steep`. First may need the RBS collection:
552
+
553
+ bundle exec rake rbs:install_collection
554
+
555
+ Now can run `steep`:
556
+
557
+ bundle exec rake steep
558
+
559
+ ### Proto Generation
560
+
561
+ Run:
562
+
563
+ bundle exec rake proto:generate