@temporalio/core-bridge 1.14.2-canary-release-testing.0 → 1.16.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 (233) hide show
  1. package/Cargo.lock +794 -650
  2. package/bridge-macros/src/derive_tryintojs.rs +40 -0
  3. package/lib/native.d.ts +24 -3
  4. package/package.json +4 -4
  5. package/releases/aarch64-apple-darwin/index.node +0 -0
  6. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  7. package/releases/x86_64-apple-darwin/index.node +0 -0
  8. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  9. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  10. package/sdk-core/.github/workflows/per-pr.yml +6 -6
  11. package/sdk-core/AGENTS.md +42 -31
  12. package/sdk-core/Cargo.toml +4 -1
  13. package/sdk-core/README.md +19 -13
  14. package/sdk-core/crates/client/Cargo.toml +4 -0
  15. package/sdk-core/crates/client/README.md +139 -0
  16. package/sdk-core/crates/client/src/async_activity_handle.rs +297 -0
  17. package/sdk-core/crates/client/src/callback_based.rs +7 -0
  18. package/sdk-core/crates/client/src/errors.rs +294 -0
  19. package/sdk-core/crates/client/src/{raw.rs → grpc.rs} +370 -159
  20. package/sdk-core/crates/client/src/lib.rs +920 -1326
  21. package/sdk-core/crates/client/src/metrics.rs +24 -33
  22. package/sdk-core/crates/client/src/options_structs.rs +457 -0
  23. package/sdk-core/crates/client/src/replaceable.rs +5 -4
  24. package/sdk-core/crates/client/src/request_extensions.rs +8 -9
  25. package/sdk-core/crates/client/src/retry.rs +99 -54
  26. package/sdk-core/crates/client/src/{worker/mod.rs → worker.rs} +104 -29
  27. package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
  28. package/sdk-core/crates/common/Cargo.toml +62 -3
  29. package/sdk-core/crates/common/build.rs +742 -12
  30. package/sdk-core/crates/common/protos/api_upstream/.github/workflows/ci.yml +2 -0
  31. package/sdk-core/crates/common/protos/api_upstream/.github/workflows/create-release.yml +0 -5
  32. package/sdk-core/crates/common/protos/api_upstream/Makefile +2 -1
  33. package/sdk-core/crates/common/protos/api_upstream/README.md +8 -0
  34. package/sdk-core/crates/common/protos/api_upstream/cmd/check-path-conflicts/main.go +137 -0
  35. package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv2.json +3329 -2647
  36. package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +2734 -708
  37. package/sdk-core/crates/common/protos/api_upstream/temporal/api/activity/v1/message.proto +155 -3
  38. package/sdk-core/crates/common/protos/api_upstream/temporal/api/command/v1/message.proto +26 -0
  39. package/sdk-core/crates/common/protos/api_upstream/temporal/api/common/v1/message.proto +8 -1
  40. package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +27 -1
  41. package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/activity.proto +81 -0
  42. package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/event_type.proto +4 -0
  43. package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +4 -0
  44. package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +15 -0
  45. package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +63 -15
  46. package/sdk-core/crates/common/protos/api_upstream/temporal/api/errordetails/v1/message.proto +8 -0
  47. package/sdk-core/crates/common/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -0
  48. package/sdk-core/crates/common/protos/api_upstream/temporal/api/history/v1/message.proto +111 -17
  49. package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +21 -0
  50. package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +20 -1
  51. package/sdk-core/crates/common/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +4 -0
  52. package/sdk-core/crates/common/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
  53. package/sdk-core/crates/common/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -0
  54. package/sdk-core/crates/common/protos/api_upstream/temporal/api/worker/v1/message.proto +4 -7
  55. package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflow/v1/message.proto +80 -22
  56. package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +347 -23
  57. package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +242 -43
  58. package/sdk-core/crates/common/protos/local/temporal/sdk/core/core_interface.proto +15 -0
  59. package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +9 -2
  60. package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +8 -0
  61. package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +22 -5
  62. package/sdk-core/crates/common/src/activity_definition.rs +20 -0
  63. package/sdk-core/crates/common/src/data_converters.rs +770 -0
  64. package/sdk-core/crates/common/src/envconfig.rs +5 -0
  65. package/sdk-core/crates/common/src/lib.rs +15 -211
  66. package/sdk-core/crates/common/src/payload_visitor.rs +648 -0
  67. package/sdk-core/crates/common/src/priority.rs +110 -0
  68. package/sdk-core/crates/common/src/protos/canned_histories.rs +19 -0
  69. package/sdk-core/crates/common/src/protos/history_builder.rs +45 -0
  70. package/sdk-core/crates/common/src/protos/history_info.rs +2 -0
  71. package/sdk-core/crates/common/src/protos/mod.rs +134 -27
  72. package/sdk-core/crates/common/src/protos/task_token.rs +3 -3
  73. package/sdk-core/crates/common/src/protos/utilities.rs +11 -0
  74. package/sdk-core/crates/{sdk-core → common}/src/telemetry/log_export.rs +11 -16
  75. package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
  76. package/sdk-core/crates/common/src/telemetry/metrics.rs +272 -225
  77. package/sdk-core/crates/{sdk-core → common}/src/telemetry/otel.rs +8 -13
  78. package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_meter.rs +49 -50
  79. package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_server.rs +2 -3
  80. package/sdk-core/crates/common/src/telemetry.rs +278 -19
  81. package/sdk-core/crates/common/src/worker.rs +68 -636
  82. package/sdk-core/crates/common/src/workflow_definition.rs +60 -0
  83. package/sdk-core/crates/macros/Cargo.toml +5 -1
  84. package/sdk-core/crates/macros/src/activities_definitions.rs +585 -0
  85. package/sdk-core/crates/macros/src/fsm_impl.rs +507 -0
  86. package/sdk-core/crates/macros/src/lib.rs +138 -512
  87. package/sdk-core/crates/macros/src/macro_utils.rs +106 -0
  88. package/sdk-core/crates/macros/src/workflow_definitions.rs +1224 -0
  89. package/sdk-core/crates/sdk/Cargo.toml +19 -6
  90. package/sdk-core/crates/sdk/README.md +415 -0
  91. package/sdk-core/crates/sdk/src/activities.rs +417 -0
  92. package/sdk-core/crates/sdk/src/interceptors.rs +1 -1
  93. package/sdk-core/crates/sdk/src/lib.rs +759 -442
  94. package/sdk-core/crates/sdk/src/workflow_context/options.rs +64 -35
  95. package/sdk-core/crates/sdk/src/workflow_context.rs +1033 -289
  96. package/sdk-core/crates/sdk/src/workflow_future.rs +277 -213
  97. package/sdk-core/crates/sdk/src/workflows.rs +711 -0
  98. package/sdk-core/crates/sdk-core/Cargo.toml +59 -65
  99. package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +45 -54
  100. package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +1 -1
  101. package/sdk-core/crates/sdk-core/src/abstractions.rs +6 -10
  102. package/sdk-core/crates/sdk-core/src/core_tests/activity_tasks.rs +6 -5
  103. package/sdk-core/crates/sdk-core/src/core_tests/mod.rs +22 -21
  104. package/sdk-core/crates/sdk-core/src/core_tests/queries.rs +21 -25
  105. package/sdk-core/crates/sdk-core/src/core_tests/replay_flag.rs +7 -10
  106. package/sdk-core/crates/sdk-core/src/core_tests/updates.rs +14 -17
  107. package/sdk-core/crates/sdk-core/src/core_tests/workers.rs +647 -27
  108. package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +46 -41
  109. package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +13 -16
  110. package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
  111. package/sdk-core/crates/sdk-core/src/lib.rs +60 -123
  112. package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
  113. package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +411 -32
  114. package/sdk-core/crates/sdk-core/src/protosext/mod.rs +2 -2
  115. package/sdk-core/crates/sdk-core/src/replay/mod.rs +14 -5
  116. package/sdk-core/crates/sdk-core/src/telemetry/metrics.rs +183 -198
  117. package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -281
  118. package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +35 -16
  119. package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
  120. package/sdk-core/crates/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +1 -0
  121. package/sdk-core/crates/sdk-core/src/worker/activities/local_activities.rs +11 -14
  122. package/sdk-core/crates/sdk-core/src/worker/activities.rs +16 -19
  123. package/sdk-core/crates/sdk-core/src/worker/client/mocks.rs +11 -5
  124. package/sdk-core/crates/sdk-core/src/worker/client.rs +104 -86
  125. package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +10 -14
  126. package/sdk-core/crates/sdk-core/src/worker/mod.rs +1175 -241
  127. package/sdk-core/crates/sdk-core/src/worker/nexus.rs +150 -23
  128. package/sdk-core/crates/sdk-core/src/worker/slot_provider.rs +2 -2
  129. package/sdk-core/crates/sdk-core/src/worker/tuner/fixed_size.rs +2 -2
  130. package/sdk-core/crates/sdk-core/src/worker/tuner/resource_based.rs +25 -27
  131. package/sdk-core/crates/sdk-core/src/worker/tuner.rs +64 -44
  132. package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
  133. package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +5 -8
  134. package/sdk-core/crates/sdk-core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +21 -22
  135. package/sdk-core/crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs +28 -4
  136. package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +20 -41
  137. package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +50 -9
  138. package/sdk-core/crates/sdk-core/src/worker/workflow/run_cache.rs +4 -7
  139. package/sdk-core/crates/sdk-core/src/worker/workflow/wft_extraction.rs +2 -4
  140. package/sdk-core/crates/sdk-core/src/worker/workflow/wft_poller.rs +8 -9
  141. package/sdk-core/crates/sdk-core/src/worker/workflow/workflow_stream.rs +1 -3
  142. package/sdk-core/crates/sdk-core/tests/activities_procmacro.rs +6 -0
  143. package/sdk-core/crates/sdk-core/tests/activities_trybuild/basic_pass.rs +54 -0
  144. package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.rs +18 -0
  145. package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.stderr +5 -0
  146. package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.rs +14 -0
  147. package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.stderr +5 -0
  148. package/sdk-core/crates/sdk-core/tests/activities_trybuild/multi_arg_pass.rs +48 -0
  149. package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_input_pass.rs +14 -0
  150. package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_return_type_pass.rs +19 -0
  151. package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +14 -5
  152. package/sdk-core/crates/sdk-core/tests/common/activity_functions.rs +55 -0
  153. package/sdk-core/crates/sdk-core/tests/common/mod.rs +281 -236
  154. package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
  155. package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +9 -14
  156. package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -66
  157. package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +306 -268
  158. package/sdk-core/crates/sdk-core/tests/integ_tests/async_activity_client_tests.rs +230 -0
  159. package/sdk-core/crates/sdk-core/tests/integ_tests/client_tests.rs +94 -57
  160. package/sdk-core/crates/sdk-core/tests/integ_tests/data_converter_tests.rs +381 -0
  161. package/sdk-core/crates/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +37 -38
  162. package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +49 -40
  163. package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +447 -300
  164. package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +50 -45
  165. package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +157 -157
  166. package/sdk-core/crates/sdk-core/tests/integ_tests/queries_tests.rs +103 -89
  167. package/sdk-core/crates/sdk-core/tests/integ_tests/update_tests.rs +609 -463
  168. package/sdk-core/crates/sdk-core/tests/integ_tests/visibility_tests.rs +80 -62
  169. package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +389 -265
  170. package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +250 -185
  171. package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -49
  172. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_client_tests.rs +180 -0
  173. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/activities.rs +437 -327
  174. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -58
  175. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -30
  176. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -251
  177. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/client_interactions.rs +552 -0
  178. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +110 -46
  179. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -149
  180. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -32
  181. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1040
  182. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -43
  183. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +402 -245
  184. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +343 -207
  185. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/queries.rs +415 -0
  186. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/replay.rs +96 -36
  187. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs +155 -140
  188. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -113
  189. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -44
  190. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -48
  191. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -56
  192. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +365 -242
  193. package/sdk-core/crates/sdk-core/tests/main.rs +22 -16
  194. package/sdk-core/crates/sdk-core/tests/manual_tests.rs +233 -187
  195. package/sdk-core/crates/sdk-core/tests/runner.rs +4 -6
  196. package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +73 -27
  197. package/sdk-core/crates/sdk-core/tests/shared_tests/priority.rs +107 -84
  198. package/sdk-core/crates/sdk-core/tests/workflows_procmacro.rs +6 -0
  199. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.rs +26 -0
  200. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.stderr +5 -0
  201. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/basic_pass.rs +49 -0
  202. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/minimal_pass.rs +21 -0
  203. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.rs +26 -0
  204. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.stderr +5 -0
  205. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.rs +21 -0
  206. package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.stderr +5 -0
  207. package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +8 -1
  208. package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +37 -26
  209. package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +180 -87
  210. package/sdk-core/crates/sdk-core-c-bridge/src/lib.rs +89 -5
  211. package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +10 -16
  212. package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +59 -67
  213. package/sdk-core/crates/sdk-core-c-bridge/src/testing.rs +10 -10
  214. package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +57 -22
  215. package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +108 -12
  216. package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +9 -52
  217. package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +74 -91
  218. package/sdk-core/rustfmt.toml +2 -1
  219. package/src/client.rs +206 -289
  220. package/src/helpers/try_into_js.rs +88 -2
  221. package/src/metrics.rs +277 -35
  222. package/src/runtime.rs +94 -45
  223. package/src/testing.rs +9 -16
  224. package/src/worker.rs +86 -68
  225. package/ts/native.ts +39 -3
  226. package/sdk-core/crates/client/src/workflow_handle/mod.rs +0 -212
  227. package/sdk-core/crates/common/src/errors.rs +0 -85
  228. package/sdk-core/crates/common/tests/worker_task_types_test.rs +0 -129
  229. package/sdk-core/crates/macros/LICENSE.txt +0 -21
  230. package/sdk-core/crates/sdk/src/activity_context.rs +0 -238
  231. package/sdk-core/crates/sdk/src/app_data.rs +0 -37
  232. package/sdk-core/crates/sdk-core/tests/integ_tests/activity_functions.rs +0 -5
  233. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
@@ -30,6 +30,46 @@ pub fn derive_tryintojs_struct(input: &DeriveInput, data: &syn::DataStruct) -> T
30
30
  }
31
31
 
32
32
  pub fn derive_tryintojs_enum(input: &DeriveInput, data: &syn::DataEnum) -> TokenStream {
33
+ let all_unit = data
34
+ .variants
35
+ .iter()
36
+ .all(|v| matches!(v.fields, syn::Fields::Unit));
37
+ if all_unit {
38
+ derive_tryintojs_enum_as_string(input, data)
39
+ } else {
40
+ derive_tryintojs_enum_as_objects(input, data)
41
+ }
42
+ }
43
+
44
+ fn derive_tryintojs_enum_as_string(input: &DeriveInput, data: &syn::DataEnum) -> TokenStream {
45
+ let enum_ident = &input.ident;
46
+ let generics = &input.generics;
47
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
48
+
49
+ let variant_conversions = data.variants.iter().map(|v| {
50
+ let variant_ident = &v.ident;
51
+ let js_discriminant = variant_ident.to_string().to_case(Case::Camel);
52
+ quote! {
53
+ #enum_ident::#variant_ident => cx.string(#js_discriminant)
54
+ }
55
+ });
56
+
57
+ let expanded = quote! {
58
+ impl #impl_generics crate::helpers::TryIntoJs for #enum_ident #ty_generics #where_clause {
59
+ type Output = neon::types::JsString;
60
+
61
+ fn try_into_js<'a>(self, cx: &mut impl neon::prelude::Context<'a>) -> neon::result::JsResult<'a, Self::Output> {
62
+ Ok(match self {
63
+ #(#variant_conversions),*
64
+ })
65
+ }
66
+ }
67
+ };
68
+
69
+ TokenStream::from(expanded)
70
+ }
71
+
72
+ fn derive_tryintojs_enum_as_objects(input: &DeriveInput, data: &syn::DataEnum) -> TokenStream {
33
73
  let enum_ident = &input.ident;
34
74
  let generics = &input.generics;
35
75
  let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
package/lib/native.d.ts CHANGED
@@ -57,7 +57,7 @@ export type LogExporterOptions = {
57
57
  filter: string;
58
58
  receiver: (entries: JsonString<LogEntry>[]) => void;
59
59
  };
60
- export type MetricExporterOptions = PrometheusMetricsExporterOptions | OtelMetricsExporterOptions | null;
60
+ export type MetricExporterOptions = PrometheusMetricsExporterOptions | OtelMetricsExporterOptions | BufferedMetricsExporterOptions | null;
61
61
  export interface PrometheusMetricsExporterOptions {
62
62
  type: 'prometheus';
63
63
  socketAddr: string;
@@ -78,6 +78,11 @@ export interface OtelMetricsExporterOptions {
78
78
  histogramBucketOverrides: Record<string, number[]>;
79
79
  protocol: 'http' | 'grpc';
80
80
  }
81
+ export interface BufferedMetricsExporterOptions {
82
+ type: 'buffer';
83
+ maxBufferSize: number;
84
+ useSecondsForDurations: boolean;
85
+ }
81
86
  export declare function newClient(runtime: Runtime, clientOptions: ClientOptions): Promise<Client>;
82
87
  export declare function clientUpdateHeaders(client: Client, headers: Record<string, MetadataValue>): void;
83
88
  export declare function clientUpdateApiKey(client: Client, apiKey: string): void;
@@ -127,7 +132,7 @@ export interface RpcCall {
127
132
  timeout: Option<number>;
128
133
  }
129
134
  export declare function newWorker(client: Client, workerOptions: WorkerOptions): Worker;
130
- export declare function workerValidate(worker: Worker): Promise<void>;
135
+ export declare function workerValidate(worker: Worker): Promise<Buffer>;
131
136
  export declare function workerPollWorkflowActivation(worker: Worker): Promise<Buffer>;
132
137
  export declare function workerCompleteWorkflowActivation(worker: Worker, result: Buffer): Promise<void>;
133
138
  export declare function workerPollActivityTask(worker: Worker): Promise<Buffer>;
@@ -137,6 +142,7 @@ export declare function workerPollNexusTask(worker: Worker): Promise<Buffer>;
137
142
  export declare function workerCompleteNexusTask(worker: Worker, result: Buffer): Promise<void>;
138
143
  export declare function workerInitiateShutdown(worker: Worker): void;
139
144
  export declare function workerFinalizeShutdown(worker: Worker): Promise<void>;
145
+ export declare function workerReplaceClient(worker: Worker, client: Client): void;
140
146
  export interface Worker {
141
147
  type: 'worker';
142
148
  }
@@ -186,7 +192,7 @@ export type PollerBehavior = {
186
192
  export type WorkerDeploymentOptions = {
187
193
  version: WorkerDeploymentVersion;
188
194
  useWorkerVersioning: boolean;
189
- defaultVersioningBehavior: VersioningBehavior;
195
+ defaultVersioningBehavior: Option<VersioningBehavior>;
190
196
  };
191
197
  export type WorkerDeploymentVersion = {
192
198
  buildId: string;
@@ -348,4 +354,19 @@ export declare function recordMetricHistogramValue(histogram: MetricHistogram, v
348
354
  export declare function recordMetricHistogramF64Value(histogram: MetricHistogramF64, value: number, attrs: JsonString<MetricAttributes>): void;
349
355
  export declare function setMetricGaugeValue(gauge: MetricGauge, value: number, attrs: JsonString<MetricAttributes>): void;
350
356
  export declare function setMetricGaugeF64Value(gauge: MetricGaugeF64, value: number, attrs: JsonString<MetricAttributes>): void;
357
+ export declare function runtimeRetrieveBufferedMetrics(runtime: Runtime): BufferedMetricUpdate[];
358
+ export interface BufferedMetricUpdate {
359
+ metric: BufferedMetric;
360
+ value: number;
361
+ attributes: MetricAttributes;
362
+ }
363
+ export interface BufferedMetric {
364
+ name: string;
365
+ description: string;
366
+ unit: string;
367
+ kind: BufferedMetricKind;
368
+ valueType: BufferedMetricValueType;
369
+ }
370
+ export type BufferedMetricKind = 'counter' | 'histogram' | 'gauge';
371
+ export type BufferedMetricValueType = 'int' | 'float';
351
372
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/core-bridge",
3
- "version": "1.14.2-canary-release-testing.0",
3
+ "version": "1.16.0",
4
4
  "description": "Temporal.io SDK Core<>Node bridge",
5
5
  "main": "index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
16
  "@grpc/grpc-js": "^1.12.4",
17
- "@temporalio/common": "1.14.2-canary-release-testing.0"
17
+ "@temporalio/common": "1.16.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "arg": "^5.0.2",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "homepage": "https://github.com/temporalio/sdk-typescript/tree/main/packages/core-bridge",
33
33
  "engines": {
34
- "node": ">= 18.0.0"
34
+ "node": ">= 20.0.0"
35
35
  },
36
36
  "files": [
37
37
  "bridge-macros",
@@ -56,6 +56,6 @@
56
56
  "build-rust-release": "pnpm run build-rust --release",
57
57
  "format": "cargo fmt",
58
58
  "lint": "cargo clippy --fix --allow-staged",
59
- "lint.check": "cargo clippy"
59
+ "lint:check": "cargo clippy"
60
60
  }
61
61
  }
@@ -25,7 +25,7 @@ jobs:
25
25
  submodules: recursive
26
26
  - uses: dtolnay/rust-toolchain@stable
27
27
  with:
28
- toolchain: 1.90.0
28
+ toolchain: 1.92.0
29
29
  - name: Install protoc
30
30
  uses: arduino/setup-protoc@v3
31
31
  with:
@@ -64,7 +64,7 @@ jobs:
64
64
  - uses: actions/checkout@v4
65
65
  - uses: dtolnay/rust-toolchain@stable
66
66
  with:
67
- toolchain: 1.90.0
67
+ toolchain: 1.92.0
68
68
  - name: Install protoc
69
69
  uses: arduino/setup-protoc@v3
70
70
  with:
@@ -143,7 +143,7 @@ jobs:
143
143
  - uses: actions/checkout@v4
144
144
  - uses: dtolnay/rust-toolchain@stable
145
145
  with:
146
- toolchain: 1.90.0
146
+ toolchain: 1.92.0
147
147
  - name: Install protoc
148
148
  uses: arduino/setup-protoc@v3
149
149
  with:
@@ -176,7 +176,7 @@ jobs:
176
176
  - uses: actions/checkout@v4
177
177
  - uses: dtolnay/rust-toolchain@stable
178
178
  with:
179
- toolchain: 1.90.0
179
+ toolchain: 1.92.0
180
180
  - name: Install protoc
181
181
  uses: arduino/setup-protoc@v3
182
182
  with:
@@ -201,7 +201,7 @@ jobs:
201
201
  - uses: actions/checkout@v4
202
202
  - uses: dtolnay/rust-toolchain@stable
203
203
  with:
204
- toolchain: 1.90.0
204
+ toolchain: 1.92.0
205
205
  - name: Install protoc
206
206
  uses: arduino/setup-protoc@v3
207
207
  with:
@@ -222,7 +222,7 @@ jobs:
222
222
  - uses: actions/checkout@v4
223
223
  - uses: dtolnay/rust-toolchain@stable
224
224
  with:
225
- toolchain: 1.90.0
225
+ toolchain: 1.92.0
226
226
  - name: Install protoc
227
227
  uses: arduino/setup-protoc@v3
228
228
  with:
@@ -3,51 +3,48 @@
3
3
  This repository provides a Rust workspace for the Temporal Core SDK and related crates. Use this
4
4
  document as your quick reference when submitting pull requests.
5
5
 
6
- ## Where Things Are
6
+ ## Requirements for coding agents
7
+
8
+ - Always use `cargo integ-test <test_name>` for running integration tests. Do not run them directly. If you have added `dbg!` or println statements, you must add `-- --nocapture` to see them.
9
+ - Unit tests may be run with `cargo test`. If you are about to run a test, you do not need to run
10
+ `cargo build` separately first. Just run the test, and it will build. Running `cargo build --test`
11
+ DOES NOT build integration tests. Use `cargo lint` for checking if integration tests compile
12
+ without running them.
13
+ - Always use `cargo lint` for checking lints / clippy. Do not use clippy directly.
14
+ - It is EXTREMELY IMPORTANT that any added comments should explain why something needs to be done,
15
+ rather than what it is. Comments that simply state a fact easily understood from type signatures
16
+ or other context should NEVER be added. Always prefer to avoid a comment unless it truly is
17
+ clarifying something nonobvious.
18
+ - Always make every attempt to avoid explicit sleeps in test code. Instead rely on synchronization
19
+ techniques like channels, Notify, etc.
20
+ - Rust compilation can take some time. Do not interrupt builds or tests unless they are taking more
21
+ than 5 minutes. When making changes that may break integration tests, after compiling, run
22
+ integration tests with `timeout 180`, as it is possible to introduce test hangs.
23
+ - DO NOT put use statements in function scope. Always put them at the top of the file, unless doing
24
+ so helps prevent ambiguous method resolution because of traits. Putting them at the top of a tests module is also acceptable.
7
25
 
8
- - `crates` - All crates in the workspace.
9
- - `crates/core/` – implementation of the core SDK
10
- - `crates/client/` – clients for communicating with Temporal clusters
11
- - `crates/core-api/` – API definitions exposed by core
12
- - `crates/core-c-bridge/` – C interface for core
13
- - `crates/sdk/` – pre-alpha Rust SDK built on top of core (used mainly for tests)
14
- - `crates/sdk-core-protos/` – protobuf definitions shared across crates
15
- - `crates/fsm/` – state machine implementation and macros
16
- - `crates/core/tests/` – integration, heavy, and manual tests
17
- - `arch_docs/` – architectural design documents
18
- - Contributor guide: `README.md`
19
- - `target/` - This contains compiled files. You never need to look in here.
20
26
 
21
27
  ## Repo Specific Utilities
22
28
 
23
29
  - `.cargo/config.toml` defines useful cargo aliases:
24
- - `cargo lint` – run clippy on workspace crates
25
- - `cargo test-lint` – run clippy on tests
30
+ - `cargo lint` – run clippy on workspace crates and integration tests
31
+ - `cargo test-lint` – run clippy on unit tests
26
32
  - `cargo integ-test` – run the integration test runner
27
- - `etc` - Various helper scripts and configuration
28
- - `etc/docker` - Docker compose files to help with CI or more complex local testing
29
33
 
30
34
  ## Building and Testing
31
35
 
32
36
  The following commands are enforced for each pull request (see `README.md`):
33
37
 
34
38
  ```bash
35
- cargo build # build all crates
36
- cargo test # run unit tests
37
- cargo integ-test # integration tests (starts ephemeral server by default)
39
+ cargo fmt --all --check # ensure code is formatted
40
+ cargo build # build all crates
41
+ cargo lint # run lints
42
+ cargo test-lint # run lints on tests
43
+ cargo test # run unit tests
44
+ cargo integ-test # integration tests (starts ephemeral server by default)
38
45
  cargo test --test heavy_tests # load tests -- agents do not need to run this and should not
39
46
  ```
40
47
 
41
- Rust compilation can take some time. Do not interrupt builds or tests unless they are taking more
42
- than 10 minutes.
43
-
44
- Additional checks:
45
-
46
- ```bash
47
- cargo fmt --all # format code
48
- cargo clippy --all -- -D warnings # lint
49
- ```
50
-
51
48
  Documentation can be generated with `cargo doc`.
52
49
 
53
50
  ## Expectations for Pull Requests
@@ -70,9 +67,23 @@ Reviewers will look for:
70
67
  - Clear and concise code following existing style (see `README.md` for error handling guidance)
71
68
  - Documentation updates for any public API changes
72
69
 
70
+ ## Where Things Are
71
+
72
+ - `crates` - All crates in the workspace.
73
+ - `crates/client/` – clients for communicating with Temporal clusters
74
+ - `crates/common/` – Common functionality & protobuf definitions
75
+ - `crates/macros/` – procedural macro implementations
76
+ - `crates/sdk/` – Rust SDK built on top of core
77
+ - `crates/sdk-core/` – implementation of the core SDK
78
+ - `crates/sdk-core/tests/` – integration, heavy, and manual tests
79
+ - `crates/sdk-core-c-bridge/` – C interface for core
80
+ - `arch_docs/` – architectural design documents
81
+ - Contributor guide: `README.md`
82
+ - `target/` - This contains compiled files. You never need to look in here.
83
+
73
84
  ## Notes
74
85
 
75
86
  - Fetch workflow histories with `cargo run --bin histfetch <workflow_id> [run_id]` (binary lives in
76
87
  `crates/core/src/histfetch.rs`).
77
- - Protobuf files under `crates/sdk-core-protos/protos/api_upstream` are a git subtree; see
88
+ - Protobuf files under `crates/common/protos/api_upstream` are a git subtree; see
78
89
  `README.md` for update instructions.
@@ -14,7 +14,7 @@ license = "MIT"
14
14
  license-file = "LICENSE.txt"
15
15
 
16
16
  [workspace.dependencies]
17
- derive_builder = "0.20"
17
+ bon = { version = "3", features = ["implied-bounds"] }
18
18
  derive_more = { version = "2.0", features = [
19
19
  "constructor",
20
20
  "display",
@@ -30,6 +30,9 @@ tonic-prost-build = "0.14"
30
30
  opentelemetry = { version = "0.31", features = ["metrics"] }
31
31
  prost = "0.14"
32
32
  prost-types = { version = "0.7", package = "prost-wkt-types" }
33
+ pbjson = "0.9"
34
+ pbjson-types = "0.9"
35
+ pbjson-build = "0.9"
33
36
 
34
37
  [workspace.lints.rust]
35
38
  unreachable_pub = "warn"
@@ -7,6 +7,20 @@ Core SDK that can be used as a base for other Temporal SDKs. It is currently use
7
7
  - [.NET SDK](https://github.com/temporalio/sdk-dotnet/)
8
8
  - [Ruby SDK](https://github.com/temporalio/sdk-ruby/)
9
9
 
10
+ # Temporal Rust SDK
11
+
12
+ [![crates.io](https://img.shields.io/crates/v/temporalio-sdk.svg)](https://crates.io/crates/temporalio-sdk)
13
+ [![docs.rs](https://docs.rs/temporalio-sdk/badge.svg)](https://docs.rs/temporalio-sdk)
14
+
15
+ Currently prerelease, see more in the [SDK README.md](crates/sdk/README.md)
16
+
17
+ # Temporal Rust Client
18
+
19
+ [![crates.io](https://img.shields.io/crates/v/temporalio-sdk.svg)](https://crates.io/crates/temporalio-client)
20
+ [![docs.rs](https://docs.rs/temporalio-sdk/badge.svg)](https://docs.rs/temporalio-client)
21
+
22
+ Currently prerelease, see more in the [client README.md](crates/client/README.md)
23
+
10
24
  # Documentation
11
25
 
12
26
  Core SDK documentation can be generated with `cargo doc`, output will be placed in the
@@ -87,13 +101,13 @@ equivalent.
87
101
 
88
102
  ## Proto files
89
103
 
90
- This repo uses a subtree for upstream protobuf files. The path `sdk-core-protos/protos/api_upstream`
104
+ This repo uses a subtree for upstream protobuf files. The path `crates/common/protos/api_upstream`
91
105
  is a subtree. To update it, use:
92
106
 
93
- `git pull --squash --rebase=false -s subtree ssh://git@github.com/temporalio/api.git master --allow-unrelated-histories`
107
+ `git pull --squash --rebase=false -s subtree -X subtree=crates/common/protos/api_upstream ssh://git@github.com/temporalio/api.git master --allow-unrelated-histories`
94
108
 
95
109
  Do not question why this git command is the way it is. It is not our place to interpret git's ways.
96
- This same approach can be taken for updating `sdk-core-protos/protos/api_cloud_upstream` from the
110
+ This same approach can be taken for updating `crates/common/protos/api_cloud_upstream` from the
97
111
  `api-cloud` repo.
98
112
 
99
113
  The java testserver protos are also pulled from the sdk-java repo, but since we only need a
@@ -103,9 +117,9 @@ subdirectory of that repo, we just copy the files with read-tree:
103
117
  # add sdk-java as a remote if you have not already
104
118
  git remote add -f -t master --no-tags testsrv-protos git@github.com:temporalio/sdk-java.git
105
119
  # delete existing protos
106
- git rm -rf sdk-core-protos/protos/testsrv_upstream
120
+ git rm -rf crates/common/protos/testsrv_upstream
107
121
  # pull from upstream & commit
108
- git read-tree --prefix sdk-core-protos/protos/testsrv_upstream -u testsrv-protos/master:temporal-test-server/src/main/proto
122
+ git read-tree --prefix crates/common/protos/testsrv_upstream -u testsrv-protos/master:temporal-test-server/src/main/proto
109
123
  git commit
110
124
  ```
111
125
 
@@ -127,11 +141,3 @@ Any error which is returned from a public interface should be well-typed, and we
127
141
 
128
142
  Errors returned from things only used in testing are free to use
129
143
  [anyhow](https://github.com/dtolnay/anyhow) for less verbosity.
130
-
131
- # The Rust "SDK"
132
-
133
- This repo contains a *prototype* Rust sdk in the `sdk/` directory. This SDK should be considered
134
- pre-alpha in terms of its API surface. Since it's still using Core underneath, it is generally
135
- functional. We do not currently have any firm plans to productionize this SDK. If you want to write
136
- workflows and activities in Rust, feel free to use it - but be aware that the API may change at any
137
- time without warning and we do not provide any support guarantees.
@@ -9,9 +9,11 @@ homepage = "https://temporal.io/"
9
9
  repository = "https://github.com/temporalio/sdk-core"
10
10
  keywords = ["temporal", "workflow"]
11
11
  categories = ["development-tools"]
12
+ readme = "README.md"
12
13
 
13
14
  [features]
14
15
  telemetry = ["dep:opentelemetry"]
16
+ core-based-sdk = []
15
17
 
16
18
  [dependencies]
17
19
  anyhow = "1.0"
@@ -42,10 +44,12 @@ rand = "0.9.2"
42
44
 
43
45
  [dependencies.temporalio-common]
44
46
  path = "../common"
47
+ version = "0.1"
45
48
 
46
49
  [dev-dependencies]
47
50
  assert_matches = "1"
48
51
  mockall = "0.13"
52
+ prost = "0.14"
49
53
  rstest = "0.26"
50
54
 
51
55
  [lints]
@@ -0,0 +1,139 @@
1
+ # Temporal Rust Client
2
+
3
+ [![crates.io](https://img.shields.io/crates/v/temporalio-client.svg)](https://crates.io/crates/temporalio-client)
4
+ [![docs.rs](https://docs.rs/temporalio-client/badge.svg)](https://docs.rs/temporalio-client)
5
+
6
+ This crate provides a Rust client for interacting with the Temporal service. It can be used
7
+ standalone to start and manage workflows, or together with the
8
+ [`temporalio-sdk`](https://crates.io/crates/temporalio-sdk) crate to run workers.
9
+
10
+ ⚠️ **This crate is under active development and should be considered prerelease.** The API can and
11
+ will continue to evolve.
12
+
13
+ ## Quick Start
14
+
15
+ ### Connecting and Starting Workflows
16
+
17
+ ```rust
18
+ use temporalio_client::{
19
+ Client, ClientOptions, Connection, ConnectionOptions,
20
+ WorkflowOptions, GetWorkflowResultOptions,
21
+ };
22
+ use temporalio_sdk_core::{Url, CoreRuntime, RuntimeOptions};
23
+ use std::str::FromStr;
24
+
25
+ #[tokio::main]
26
+ async fn main() -> Result<(), Box<dyn std::error::Error>> {
27
+ let connection = Connection::connect(
28
+ ConnectionOptions::new(Url::from_str("http://localhost:7233")?)
29
+ .identity("my-client".to_string())
30
+ .build()
31
+ ).await?;
32
+
33
+ // "default" is your namespace
34
+ let client = Client::new(connection, ClientOptions::new("default").build());
35
+
36
+ // Start a workflow
37
+ let handle = client.start_workflow(
38
+ GreetingWorkflow::run,
39
+ "World".to_string(),
40
+ WorkflowOptions::new("my-task-queue", "greeting-workflow-1").build()
41
+ ).await?;
42
+
43
+ // Wait for the result
44
+ let result = handle.get_result(GetWorkflowResultOptions::default()).await?;
45
+
46
+ Ok(())
47
+ }
48
+ ```
49
+
50
+ ### Signals, Queries, and Updates
51
+
52
+ Once you have a workflow handle, you can interact with the running workflow:
53
+
54
+ ```rust
55
+ use temporalio_client::{
56
+ SignalOptions, QueryOptions, UpdateOptions,
57
+ StartUpdateOptions, WorkflowUpdateWaitStage,
58
+ UntypedSignal,
59
+ };
60
+ use temporalio_common::data_converters::{PayloadConverter, RawValue};
61
+
62
+ // Get a handle to an existing workflow (or use one from start_workflow)
63
+ let handle = client.get_workflow_handle::<MyWorkflow>("workflow-id");
64
+
65
+ // --- Signals (fire-and-forget messages) ---
66
+ handle.signal(MyWorkflow::push_value, 42, SignalOptions::default()).await?;
67
+
68
+ // --- Queries (read workflow state) ---
69
+ let values = handle
70
+ .query(MyWorkflow::get_values, (), QueryOptions::default())
71
+ .await?;
72
+
73
+ // --- Updates (modify state and get a result) ---
74
+ let values = handle
75
+ .execute_update(MyWorkflow::add_wait_return, 100, UpdateOptions::default())
76
+ .await?;
77
+
78
+ // Start an update and wait for acceptance only
79
+ let update_handle = handle
80
+ .start_update(
81
+ MyWorkflow::add_wait_return,
82
+ 50,
83
+ StartUpdateOptions::builder()
84
+ .wait_for_stage(WorkflowUpdateWaitStage::Accepted)
85
+ .build()
86
+ )
87
+ .await?;
88
+ update_handle.get_result().await?;
89
+
90
+ // --- Untyped interactions (when types aren't known at compile time) ---
91
+ let pc = PayloadConverter::serde_json();
92
+ handle
93
+ .signal(
94
+ UntypedSignal::new("increment"),
95
+ RawValue::from_value(&25i32, &pc),
96
+ SignalOptions::default(),
97
+ )
98
+ .await?;
99
+ // UntypedQuery and UntypedUpdate work similarly
100
+ ```
101
+
102
+ ### Cancelling and Terminating Workflows
103
+
104
+ ```rust
105
+ use temporalio_client::{CancelWorkflowOptions, TerminateWorkflowOptions};
106
+
107
+ // Request cancellation (workflow can handle this gracefully)
108
+ handle.cancel(CancelWorkflowOptions::builder().reason("No longer needed").build()).await?;
109
+
110
+ // Terminate immediately (workflow cannot intercept this)
111
+ handle.terminate(TerminateWorkflowOptions::builder().reason("Emergency shutdown").build()).await?;
112
+ ```
113
+
114
+ ### Listing Workflows
115
+
116
+ ```rust
117
+ use temporalio_client::ListWorkflowsOptions;
118
+ use futures_util::StreamExt;
119
+
120
+ let mut stream = client.list_workflows(
121
+ "WorkflowType = 'GreetingWorkflow'",
122
+ ListWorkflowsOptions::builder().limit(10).build()
123
+ );
124
+
125
+ while let Some(result) = stream.next().await {
126
+ let execution = result?;
127
+ println!("Workflow: {} ({})", execution.id(), execution.workflow_type());
128
+ }
129
+ ```
130
+
131
+ ## Raw gRPC Access
132
+
133
+ For operations not covered by the high-level API, access the underlying gRPC service clients
134
+ directly:
135
+
136
+ ```rust
137
+ let mut workflowf_service = client.connection().workflow_service();
138
+ let mut operator_service = client.connection().operator_service();
139
+ ```