@temporalio/core-bridge 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/Cargo.lock +239 -382
  2. package/Cargo.toml +11 -11
  3. package/lib/native.d.ts +10 -3
  4. package/package.json +3 -3
  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/.cargo/config.toml +71 -11
  11. package/sdk-core/.clippy.toml +1 -0
  12. package/sdk-core/.github/workflows/heavy.yml +2 -0
  13. package/sdk-core/.github/workflows/per-pr.yml +50 -18
  14. package/sdk-core/ARCHITECTURE.md +44 -48
  15. package/sdk-core/Cargo.toml +26 -7
  16. package/sdk-core/README.md +4 -0
  17. package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
  18. package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
  19. package/sdk-core/arch_docs/sdks_intro.md +299 -0
  20. package/sdk-core/client/Cargo.toml +8 -7
  21. package/sdk-core/client/src/callback_based.rs +1 -2
  22. package/sdk-core/client/src/lib.rs +485 -299
  23. package/sdk-core/client/src/metrics.rs +32 -8
  24. package/sdk-core/client/src/proxy.rs +124 -5
  25. package/sdk-core/client/src/raw.rs +598 -307
  26. package/sdk-core/client/src/replaceable.rs +253 -0
  27. package/sdk-core/client/src/retry.rs +9 -6
  28. package/sdk-core/client/src/worker_registry/mod.rs +19 -3
  29. package/sdk-core/client/src/workflow_handle/mod.rs +20 -17
  30. package/sdk-core/core/Cargo.toml +100 -31
  31. package/sdk-core/core/src/core_tests/activity_tasks.rs +55 -225
  32. package/sdk-core/core/src/core_tests/mod.rs +2 -8
  33. package/sdk-core/core/src/core_tests/queries.rs +3 -5
  34. package/sdk-core/core/src/core_tests/replay_flag.rs +3 -62
  35. package/sdk-core/core/src/core_tests/updates.rs +4 -5
  36. package/sdk-core/core/src/core_tests/workers.rs +4 -3
  37. package/sdk-core/core/src/core_tests/workflow_cancels.rs +10 -7
  38. package/sdk-core/core/src/core_tests/workflow_tasks.rs +28 -291
  39. package/sdk-core/core/src/ephemeral_server/mod.rs +15 -3
  40. package/sdk-core/core/src/internal_flags.rs +11 -1
  41. package/sdk-core/core/src/lib.rs +50 -36
  42. package/sdk-core/core/src/pollers/mod.rs +5 -5
  43. package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
  44. package/sdk-core/core/src/protosext/mod.rs +13 -5
  45. package/sdk-core/core/src/protosext/protocol_messages.rs +4 -11
  46. package/sdk-core/core/src/retry_logic.rs +256 -108
  47. package/sdk-core/core/src/telemetry/metrics.rs +1 -0
  48. package/sdk-core/core/src/telemetry/mod.rs +8 -2
  49. package/sdk-core/core/src/telemetry/prometheus_meter.rs +2 -2
  50. package/sdk-core/core/src/test_help/integ_helpers.rs +971 -0
  51. package/sdk-core/core/src/test_help/mod.rs +10 -1100
  52. package/sdk-core/core/src/test_help/unit_helpers.rs +218 -0
  53. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +42 -6
  54. package/sdk-core/core/src/worker/activities/local_activities.rs +19 -19
  55. package/sdk-core/core/src/worker/activities.rs +10 -3
  56. package/sdk-core/core/src/worker/client/mocks.rs +3 -3
  57. package/sdk-core/core/src/worker/client.rs +130 -93
  58. package/sdk-core/core/src/worker/heartbeat.rs +12 -13
  59. package/sdk-core/core/src/worker/mod.rs +31 -21
  60. package/sdk-core/core/src/worker/nexus.rs +14 -3
  61. package/sdk-core/core/src/worker/slot_provider.rs +9 -0
  62. package/sdk-core/core/src/worker/tuner.rs +159 -0
  63. package/sdk-core/core/src/worker/workflow/history_update.rs +3 -265
  64. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -54
  65. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -82
  66. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -67
  67. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -192
  68. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -43
  69. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +6 -554
  70. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -71
  71. package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +102 -3
  72. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +10 -539
  73. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -139
  74. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -119
  75. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -63
  76. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +9 -4
  77. package/sdk-core/core/src/worker/workflow/mod.rs +5 -1
  78. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +8 -3
  79. package/sdk-core/core-api/Cargo.toml +4 -4
  80. package/sdk-core/core-api/src/envconfig.rs +153 -54
  81. package/sdk-core/core-api/src/lib.rs +68 -0
  82. package/sdk-core/core-api/src/telemetry/metrics.rs +2 -1
  83. package/sdk-core/core-api/src/telemetry.rs +13 -0
  84. package/sdk-core/core-c-bridge/Cargo.toml +13 -8
  85. package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +184 -22
  86. package/sdk-core/core-c-bridge/src/client.rs +462 -184
  87. package/sdk-core/core-c-bridge/src/envconfig.rs +314 -0
  88. package/sdk-core/core-c-bridge/src/lib.rs +1 -0
  89. package/sdk-core/core-c-bridge/src/random.rs +4 -4
  90. package/sdk-core/core-c-bridge/src/runtime.rs +22 -23
  91. package/sdk-core/core-c-bridge/src/testing.rs +1 -4
  92. package/sdk-core/core-c-bridge/src/tests/context.rs +31 -31
  93. package/sdk-core/core-c-bridge/src/tests/mod.rs +32 -28
  94. package/sdk-core/core-c-bridge/src/tests/utils.rs +7 -7
  95. package/sdk-core/core-c-bridge/src/worker.rs +319 -66
  96. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -1
  97. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +5 -5
  98. package/sdk-core/sdk/Cargo.toml +8 -2
  99. package/sdk-core/sdk/src/activity_context.rs +1 -1
  100. package/sdk-core/sdk/src/app_data.rs +1 -1
  101. package/sdk-core/sdk/src/interceptors.rs +1 -4
  102. package/sdk-core/sdk/src/lib.rs +1 -5
  103. package/sdk-core/sdk/src/workflow_context/options.rs +10 -1
  104. package/sdk-core/sdk/src/workflow_future.rs +1 -1
  105. package/sdk-core/sdk-core-protos/Cargo.toml +6 -6
  106. package/sdk-core/sdk-core-protos/build.rs +10 -23
  107. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +9 -1
  108. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +254 -5
  109. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +234 -5
  110. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
  111. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
  112. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
  113. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
  114. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
  115. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  116. package/sdk-core/{test-utils → sdk-core-protos}/src/canned_histories.rs +5 -5
  117. package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -2
  118. package/sdk-core/sdk-core-protos/src/lib.rs +25 -9
  119. package/sdk-core/sdk-core-protos/src/test_utils.rs +89 -0
  120. package/sdk-core/sdk-core-protos/src/utilities.rs +14 -5
  121. package/sdk-core/tests/c_bridge_smoke_test.c +10 -0
  122. package/sdk-core/tests/cloud_tests.rs +10 -8
  123. package/sdk-core/tests/common/http_proxy.rs +134 -0
  124. package/sdk-core/{test-utils/src/lib.rs → tests/common/mod.rs} +214 -281
  125. package/sdk-core/{test-utils/src → tests/common}/workflows.rs +4 -3
  126. package/sdk-core/tests/fuzzy_workflow.rs +1 -1
  127. package/sdk-core/tests/global_metric_tests.rs +8 -7
  128. package/sdk-core/tests/heavy_tests.rs +7 -3
  129. package/sdk-core/tests/integ_tests/client_tests.rs +111 -24
  130. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +14 -9
  131. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +4 -4
  132. package/sdk-core/tests/integ_tests/metrics_tests.rs +114 -14
  133. package/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
  134. package/sdk-core/tests/integ_tests/polling_tests.rs +311 -93
  135. package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
  136. package/sdk-core/tests/integ_tests/update_tests.rs +13 -7
  137. package/sdk-core/tests/integ_tests/visibility_tests.rs +26 -9
  138. package/sdk-core/tests/integ_tests/worker_tests.rs +668 -13
  139. package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +40 -24
  140. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +244 -11
  141. package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
  142. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +78 -2
  143. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +61 -2
  144. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +465 -7
  145. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +41 -2
  146. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +315 -3
  147. package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
  148. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1990 -14
  149. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +65 -2
  150. package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +123 -23
  151. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +525 -3
  152. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +65 -16
  153. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +32 -23
  154. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +126 -5
  155. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +1 -2
  156. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +124 -8
  157. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +62 -2
  158. package/sdk-core/tests/integ_tests/workflow_tests.rs +67 -8
  159. package/sdk-core/tests/main.rs +26 -17
  160. package/sdk-core/tests/manual_tests.rs +5 -1
  161. package/sdk-core/tests/runner.rs +22 -40
  162. package/sdk-core/tests/shared_tests/mod.rs +1 -1
  163. package/sdk-core/tests/shared_tests/priority.rs +1 -1
  164. package/sdk-core/{core/benches/workflow_replay.rs → tests/workflow_replay_bench.rs} +10 -5
  165. package/src/client.rs +97 -20
  166. package/src/helpers/callbacks.rs +4 -4
  167. package/src/helpers/errors.rs +7 -1
  168. package/src/helpers/handles.rs +1 -0
  169. package/src/helpers/try_from_js.rs +4 -3
  170. package/src/lib.rs +3 -2
  171. package/src/metrics.rs +3 -0
  172. package/src/runtime.rs +5 -2
  173. package/src/worker.rs +9 -12
  174. package/ts/native.ts +13 -3
  175. package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
  176. package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
  177. package/sdk-core/core/src/core_tests/determinism.rs +0 -318
  178. package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
  179. package/sdk-core/test-utils/Cargo.toml +0 -38
  180. package/sdk-core/test-utils/src/histfetch.rs +0 -28
  181. package/sdk-core/test-utils/src/interceptors.rs +0 -46
@@ -81,6 +81,8 @@ typedef struct TemporalCoreRandom TemporalCoreRandom;
81
81
 
82
82
  typedef struct TemporalCoreRuntime TemporalCoreRuntime;
83
83
 
84
+ typedef struct TemporalCoreSlotReserveCompletionCtx TemporalCoreSlotReserveCompletionCtx;
85
+
84
86
  typedef struct TemporalCoreWorker TemporalCoreWorker;
85
87
 
86
88
  typedef struct TemporalCoreWorkerReplayPusher TemporalCoreWorkerReplayPusher;
@@ -240,6 +242,53 @@ typedef void (*TemporalCoreClientRpcCallCallback)(void *user_data,
240
242
  const struct TemporalCoreByteArray *failure_message,
241
243
  const struct TemporalCoreByteArray *failure_details);
242
244
 
245
+ /**
246
+ * OrFail result for client config loading operations.
247
+ * Either success or fail will be null, but never both.
248
+ * If success is not null, it contains JSON-serialized client configuration data.
249
+ * If fail is not null, it contains UTF-8 encoded error message.
250
+ * The returned ByteArrays must be freed by the caller.
251
+ */
252
+ typedef struct TemporalCoreClientEnvConfigOrFail {
253
+ const struct TemporalCoreByteArray *success;
254
+ const struct TemporalCoreByteArray *fail;
255
+ } TemporalCoreClientEnvConfigOrFail;
256
+
257
+ /**
258
+ * Options for loading client configuration.
259
+ */
260
+ typedef struct TemporalCoreClientEnvConfigLoadOptions {
261
+ struct TemporalCoreByteArrayRef path;
262
+ struct TemporalCoreByteArrayRef data;
263
+ bool config_file_strict;
264
+ struct TemporalCoreByteArrayRef env_vars;
265
+ } TemporalCoreClientEnvConfigLoadOptions;
266
+
267
+ /**
268
+ * OrFail result for client config profile loading operations.
269
+ * Either success or fail will be null, but never both.
270
+ * If success is not null, it contains JSON-serialized client configuration profile data.
271
+ * If fail is not null, it contains UTF-8 encoded error message.
272
+ * The returned ByteArrays must be freed by the caller.
273
+ */
274
+ typedef struct TemporalCoreClientEnvConfigProfileOrFail {
275
+ const struct TemporalCoreByteArray *success;
276
+ const struct TemporalCoreByteArray *fail;
277
+ } TemporalCoreClientEnvConfigProfileOrFail;
278
+
279
+ /**
280
+ * Options for loading a specific client configuration profile.
281
+ */
282
+ typedef struct TemporalCoreClientEnvConfigProfileLoadOptions {
283
+ struct TemporalCoreByteArrayRef profile;
284
+ struct TemporalCoreByteArrayRef path;
285
+ struct TemporalCoreByteArrayRef data;
286
+ bool disable_file;
287
+ bool disable_env;
288
+ bool config_file_strict;
289
+ struct TemporalCoreByteArrayRef env_vars;
290
+ } TemporalCoreClientEnvConfigProfileLoadOptions;
291
+
243
292
  typedef union TemporalCoreMetricAttributeValue {
244
293
  struct TemporalCoreByteArrayRef string_value;
245
294
  int64_t int_value;
@@ -523,18 +572,17 @@ typedef struct TemporalCoreSlotReserveCtx {
523
572
  struct TemporalCoreByteArrayRef worker_identity;
524
573
  struct TemporalCoreByteArrayRef worker_build_id;
525
574
  bool is_sticky;
526
- void *token_src;
527
575
  } TemporalCoreSlotReserveCtx;
528
576
 
529
- typedef void (*TemporalCoreCustomReserveSlotCallback)(const struct TemporalCoreSlotReserveCtx *ctx,
530
- void *sender);
577
+ typedef void (*TemporalCoreCustomSlotSupplierReserveCallback)(const struct TemporalCoreSlotReserveCtx *ctx,
578
+ const struct TemporalCoreSlotReserveCompletionCtx *completion_ctx,
579
+ void *user_data);
531
580
 
532
- typedef void (*TemporalCoreCustomCancelReserveCallback)(void *token_source);
581
+ typedef void (*TemporalCoreCustomSlotSupplierCancelReserveCallback)(const struct TemporalCoreSlotReserveCompletionCtx *completion_ctx,
582
+ void *user_data);
533
583
 
534
- /**
535
- * Must return C#-tracked id for the permit. A zero value means no permit was reserved.
536
- */
537
- typedef uintptr_t (*TemporalCoreCustomTryReserveSlotCallback)(const struct TemporalCoreSlotReserveCtx *ctx);
584
+ typedef uintptr_t (*TemporalCoreCustomSlotSupplierTryReserveCallback)(const struct TemporalCoreSlotReserveCtx *ctx,
585
+ void *user_data);
538
586
 
539
587
  typedef enum TemporalCoreSlotInfo_Tag {
540
588
  WorkflowSlotInfo,
@@ -574,32 +622,87 @@ typedef struct TemporalCoreSlotInfo {
574
622
  typedef struct TemporalCoreSlotMarkUsedCtx {
575
623
  struct TemporalCoreSlotInfo slot_info;
576
624
  /**
577
- * C# id for the slot permit.
625
+ * Lang-issued permit ID.
578
626
  */
579
627
  uintptr_t slot_permit;
580
628
  } TemporalCoreSlotMarkUsedCtx;
581
629
 
582
- typedef void (*TemporalCoreCustomMarkSlotUsedCallback)(const struct TemporalCoreSlotMarkUsedCtx *ctx);
630
+ typedef void (*TemporalCoreCustomSlotSupplierMarkUsedCallback)(const struct TemporalCoreSlotMarkUsedCtx *ctx,
631
+ void *user_data);
583
632
 
584
633
  typedef struct TemporalCoreSlotReleaseCtx {
585
634
  const struct TemporalCoreSlotInfo *slot_info;
586
635
  /**
587
- * C# id for the slot permit.
636
+ * Lang-issued permit ID.
588
637
  */
589
638
  uintptr_t slot_permit;
590
639
  } TemporalCoreSlotReleaseCtx;
591
640
 
592
- typedef void (*TemporalCoreCustomReleaseSlotCallback)(const struct TemporalCoreSlotReleaseCtx *ctx);
641
+ typedef void (*TemporalCoreCustomSlotSupplierReleaseCallback)(const struct TemporalCoreSlotReleaseCtx *ctx,
642
+ void *user_data);
593
643
 
594
- typedef void (*TemporalCoreCustomSlotImplFreeCallback)(const struct TemporalCoreCustomSlotSupplierCallbacks *userimpl);
644
+ typedef bool (*TemporalCoreCustomSlotSupplierAvailableSlotsCallback)(uintptr_t *available_slots,
645
+ void *user_data);
646
+
647
+ typedef void (*TemporalCoreCustomSlotSupplierFreeCallback)(const struct TemporalCoreCustomSlotSupplierCallbacks *userimpl);
595
648
 
596
649
  typedef struct TemporalCoreCustomSlotSupplierCallbacks {
597
- TemporalCoreCustomReserveSlotCallback reserve;
598
- TemporalCoreCustomCancelReserveCallback cancel_reserve;
599
- TemporalCoreCustomTryReserveSlotCallback try_reserve;
600
- TemporalCoreCustomMarkSlotUsedCallback mark_used;
601
- TemporalCoreCustomReleaseSlotCallback release;
602
- TemporalCoreCustomSlotImplFreeCallback free;
650
+ /**
651
+ * Called to initiate asynchronous slot reservation. `ctx` contains information about
652
+ * reservation request. The pointer is only valid for the duration of the function call; the
653
+ * implementation should copy the data out of it for later use, and return as soon as possible.
654
+ *
655
+ * When slot is reserved, the implementation should call [`temporal_core_complete_async_reserve`]
656
+ * with the same `completion_ctx` as passed to this function. Reservation cannot be cancelled
657
+ * by Lang, but it can be cancelled by Core through [`cancel_reserve`](Self::cancel_reserve)
658
+ * callback. If reservation was cancelled, [`temporal_core_complete_async_cancel_reserve`]
659
+ * should be called instead.
660
+ *
661
+ * Slot reservation cannot error. The implementation should recover from errors and keep trying
662
+ * to reserve a slot until it eventually succeeds, or until reservation is cancelled by Core.
663
+ */
664
+ TemporalCoreCustomSlotSupplierReserveCallback reserve;
665
+ /**
666
+ * Called to cancel slot reservation. `completion_ctx` specifies which reservation is being
667
+ * cancelled; the matching [`reserve`](Self::reserve) call was made with the same `completion_ctx`.
668
+ * After cancellation, the implementation should call [`temporal_core_complete_async_cancel_reserve`]
669
+ * with the same `completion_ctx`. Calling [`temporal_core_complete_async_reserve`] is not
670
+ * needed after cancellation.
671
+ */
672
+ TemporalCoreCustomSlotSupplierCancelReserveCallback cancel_reserve;
673
+ /**
674
+ * Called to try an immediate slot reservation. The callback should return 0 if immediate
675
+ * reservation is not currently possible, or permit ID if reservation was successful. Permit ID
676
+ * is arbitrary, but must be unique among live reservations as it's later used for [`mark_used`](Self::mark_used)
677
+ * and [`release`](Self::release) callbacks.
678
+ */
679
+ TemporalCoreCustomSlotSupplierTryReserveCallback try_reserve;
680
+ /**
681
+ * Called after successful reservation to mark slot as used. See [`SlotSupplier`](temporal_sdk_core_api::worker::SlotSupplier)
682
+ * trait for details.
683
+ */
684
+ TemporalCoreCustomSlotSupplierMarkUsedCallback mark_used;
685
+ /**
686
+ * Called to free a previously reserved slot.
687
+ */
688
+ TemporalCoreCustomSlotSupplierReleaseCallback release;
689
+ /**
690
+ * Called to retrieve the number of available slots if known. If the implementation knows how
691
+ * many slots are available at the moment, it should set the value behind the `available_slots`
692
+ * pointer and return true. If that number is unknown, it should return false.
693
+ *
694
+ * This function pointer can be set to null. It will be treated as if the number of available
695
+ * slots is never known.
696
+ */
697
+ TemporalCoreCustomSlotSupplierAvailableSlotsCallback available_slots;
698
+ /**
699
+ * Called when the slot supplier is being dropped. All resources should be freed.
700
+ */
701
+ TemporalCoreCustomSlotSupplierFreeCallback free;
702
+ /**
703
+ * Passed as an extra argument to the callbacks.
704
+ */
705
+ void *user_data;
603
706
  } TemporalCoreCustomSlotSupplierCallbacks;
604
707
 
605
708
  typedef struct TemporalCoreCustomSlotSupplierCallbacksImpl {
@@ -631,6 +734,7 @@ typedef struct TemporalCoreTunerHolder {
631
734
  struct TemporalCoreSlotSupplier workflow_slot_supplier;
632
735
  struct TemporalCoreSlotSupplier activity_slot_supplier;
633
736
  struct TemporalCoreSlotSupplier local_activity_slot_supplier;
737
+ struct TemporalCoreSlotSupplier nexus_task_slot_supplier;
634
738
  } TemporalCoreTunerHolder;
635
739
 
636
740
  typedef struct TemporalCorePollerBehaviorSimpleMaximum {
@@ -670,6 +774,7 @@ typedef struct TemporalCoreWorkerOptions {
670
774
  struct TemporalCorePollerBehavior workflow_task_poller_behavior;
671
775
  float nonsticky_to_sticky_poll_ratio;
672
776
  struct TemporalCorePollerBehavior activity_task_poller_behavior;
777
+ struct TemporalCorePollerBehavior nexus_task_poller_behavior;
673
778
  bool nondeterminism_as_workflow_fail;
674
779
  struct TemporalCoreByteArrayRefArray nondeterminism_as_workflow_fail_for_types;
675
780
  } TemporalCoreWorkerOptions;
@@ -769,6 +874,20 @@ void temporal_core_client_rpc_call(struct TemporalCoreClient *client,
769
874
  void *user_data,
770
875
  TemporalCoreClientRpcCallCallback callback);
771
876
 
877
+ /**
878
+ * Load all client profiles from given sources.
879
+ * Returns ClientConfigOrFail with either success JSON or error message.
880
+ * The returned ByteArrays must be freed by the caller.
881
+ */
882
+ struct TemporalCoreClientEnvConfigOrFail temporal_core_client_env_config_load(const struct TemporalCoreClientEnvConfigLoadOptions *options);
883
+
884
+ /**
885
+ * Load a single client profile from given sources with env overrides.
886
+ * Returns ClientConfigProfileOrFail with either success JSON or error message.
887
+ * The returned ByteArrays must be freed by the caller.
888
+ */
889
+ struct TemporalCoreClientEnvConfigProfileOrFail temporal_core_client_env_config_profile_load(const struct TemporalCoreClientEnvConfigProfileLoadOptions *options);
890
+
772
891
  struct TemporalCoreMetricMeter *temporal_core_metric_meter_new(struct TemporalCoreRuntime *runtime);
773
892
 
774
893
  void temporal_core_metric_meter_free(struct TemporalCoreMetricMeter *meter);
@@ -877,6 +996,10 @@ void temporal_core_worker_poll_activity_task(struct TemporalCoreWorker *worker,
877
996
  void *user_data,
878
997
  TemporalCoreWorkerPollCallback callback);
879
998
 
999
+ void temporal_core_worker_poll_nexus_task(struct TemporalCoreWorker *worker,
1000
+ void *user_data,
1001
+ TemporalCoreWorkerPollCallback callback);
1002
+
880
1003
  void temporal_core_worker_complete_workflow_activation(struct TemporalCoreWorker *worker,
881
1004
  struct TemporalCoreByteArrayRef completion,
882
1005
  void *user_data,
@@ -887,6 +1010,11 @@ void temporal_core_worker_complete_activity_task(struct TemporalCoreWorker *work
887
1010
  void *user_data,
888
1011
  TemporalCoreWorkerCallback callback);
889
1012
 
1013
+ void temporal_core_worker_complete_nexus_task(struct TemporalCoreWorker *worker,
1014
+ struct TemporalCoreByteArrayRef completion,
1015
+ void *user_data,
1016
+ TemporalCoreWorkerCallback callback);
1017
+
890
1018
  /**
891
1019
  * Returns error if any. Must be freed if returned.
892
1020
  */
@@ -912,10 +1040,44 @@ struct TemporalCoreWorkerReplayPushResult temporal_core_worker_replay_push(struc
912
1040
  struct TemporalCoreByteArrayRef workflow_id,
913
1041
  struct TemporalCoreByteArrayRef history);
914
1042
 
915
- void temporal_core_complete_async_reserve(void *sender, uintptr_t permit_id);
1043
+ /**
1044
+ * Completes asynchronous slot reservation started by a call to [`CustomSlotSupplierCallbacks::reserve`].
1045
+ *
1046
+ * `completion_ctx` must be the same as the one passed to the matching [`reserve`](CustomSlotSupplierCallbacks::reserve)
1047
+ * call. `permit_id` is arbitrary, but must be unique among live reservations as it's later used
1048
+ * for [`mark_used`](CustomSlotSupplierCallbacks::mark_used) and [`release`](CustomSlotSupplierCallbacks::release)
1049
+ * callbacks.
1050
+ *
1051
+ * This function returns true if the reservation was completed successfully, or false if the
1052
+ * reservation was cancelled before completion. If this function returns false, the implementation
1053
+ * should call [`temporal_core_complete_async_cancel_reserve`] with the same `completion_ctx`.
1054
+ *
1055
+ * **Caution:** if this function returns true, `completion_ctx` gets freed. Afterwards, calling
1056
+ * either [`temporal_core_complete_async_reserve`] or [`temporal_core_complete_async_cancel_reserve`]
1057
+ * with the same `completion_ctx` will cause **memory corruption!**
1058
+ */
1059
+ bool temporal_core_complete_async_reserve(const struct TemporalCoreSlotReserveCompletionCtx *completion_ctx,
1060
+ uintptr_t permit_id);
916
1061
 
917
- void temporal_core_set_reserve_cancel_target(struct TemporalCoreSlotReserveCtx *ctx,
918
- void *token_ptr);
1062
+ /**
1063
+ * Completes cancellation of asynchronous slot reservation.
1064
+ *
1065
+ * Cancellation can only be initiated by Core. It's done by calling [`CustomSlotSupplierCallbacks::cancel_reserve`]
1066
+ * after an earlier call to [`CustomSlotSupplierCallbacks::reserve`].
1067
+ *
1068
+ * `completion_ctx` must be the same as the one passed to the matching [`cancel_reserve`](CustomSlotSupplierCallbacks::cancel_reserve)
1069
+ * call.
1070
+ *
1071
+ * This function returns true on successful cancellation, or false if cancellation was not
1072
+ * requested for the given `completion_ctx`. A false value indicates there's likely a logic bug in
1073
+ * the implementation where it doesn't correctly wait for [`cancel_reserve`](CustomSlotSupplierCallbacks::cancel_reserve)
1074
+ * callback to be called.
1075
+ *
1076
+ * **Caution:** if this function returns true, `completion_ctx` gets freed. Afterwards, calling
1077
+ * either [`temporal_core_complete_async_reserve`] or [`temporal_core_complete_async_cancel_reserve`]
1078
+ * with the same `completion_ctx` will cause **memory corruption!**
1079
+ */
1080
+ bool temporal_core_complete_async_cancel_reserve(const struct TemporalCoreSlotReserveCompletionCtx *completion_ctx);
919
1081
 
920
1082
  #ifdef __cplusplus
921
1083
  } // extern "C"