@temporalio/core-bridge 1.11.2 → 1.11.4

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 (119) hide show
  1. package/Cargo.lock +396 -489
  2. package/Cargo.toml +3 -2
  3. package/lib/errors.d.ts +2 -0
  4. package/lib/errors.js +7 -3
  5. package/lib/errors.js.map +1 -1
  6. package/lib/index.d.ts +8 -2
  7. package/lib/index.js.map +1 -1
  8. package/lib/worker-tuner.d.ts +111 -1
  9. package/package.json +3 -3
  10. package/releases/aarch64-apple-darwin/index.node +0 -0
  11. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  12. package/releases/x86_64-apple-darwin/index.node +0 -0
  13. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  14. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  15. package/sdk-core/.github/workflows/per-pr.yml +3 -3
  16. package/sdk-core/Cargo.toml +0 -1
  17. package/sdk-core/client/Cargo.toml +1 -2
  18. package/sdk-core/client/src/lib.rs +21 -13
  19. package/sdk-core/client/src/metrics.rs +1 -1
  20. package/sdk-core/client/src/raw.rs +46 -1
  21. package/sdk-core/core/Cargo.toml +7 -7
  22. package/sdk-core/core/benches/workflow_replay.rs +1 -1
  23. package/sdk-core/core/src/abstractions/take_cell.rs +1 -1
  24. package/sdk-core/core/src/abstractions.rs +98 -10
  25. package/sdk-core/core/src/core_tests/activity_tasks.rs +8 -2
  26. package/sdk-core/core/src/core_tests/local_activities.rs +1 -1
  27. package/sdk-core/core/src/core_tests/mod.rs +3 -3
  28. package/sdk-core/core/src/core_tests/updates.rs +104 -9
  29. package/sdk-core/core/src/core_tests/workers.rs +72 -3
  30. package/sdk-core/core/src/core_tests/workflow_tasks.rs +6 -7
  31. package/sdk-core/core/src/debug_client.rs +78 -0
  32. package/sdk-core/core/src/ephemeral_server/mod.rs +15 -5
  33. package/sdk-core/core/src/lib.rs +30 -4
  34. package/sdk-core/core/src/pollers/mod.rs +1 -1
  35. package/sdk-core/core/src/pollers/poll_buffer.rs +7 -7
  36. package/sdk-core/core/src/replay/mod.rs +4 -4
  37. package/sdk-core/core/src/telemetry/log_export.rs +2 -2
  38. package/sdk-core/core/src/telemetry/metrics.rs +69 -1
  39. package/sdk-core/core/src/telemetry/otel.rs +2 -2
  40. package/sdk-core/core/src/test_help/mod.rs +3 -3
  41. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +3 -3
  42. package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +1 -1
  43. package/sdk-core/core/src/worker/activities/local_activities.rs +68 -24
  44. package/sdk-core/core/src/worker/activities.rs +26 -15
  45. package/sdk-core/core/src/worker/client/mocks.rs +10 -4
  46. package/sdk-core/core/src/worker/client.rs +17 -0
  47. package/sdk-core/core/src/worker/mod.rs +71 -13
  48. package/sdk-core/core/src/worker/slot_provider.rs +5 -7
  49. package/sdk-core/core/src/worker/tuner/fixed_size.rs +4 -3
  50. package/sdk-core/core/src/worker/tuner/resource_based.rs +171 -32
  51. package/sdk-core/core/src/worker/tuner.rs +18 -6
  52. package/sdk-core/core/src/worker/workflow/history_update.rs +43 -13
  53. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +6 -6
  54. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +6 -5
  55. package/sdk-core/core/src/worker/workflow/managed_run.rs +3 -3
  56. package/sdk-core/core/src/worker/workflow/mod.rs +13 -7
  57. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +7 -7
  58. package/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
  59. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +11 -11
  60. package/sdk-core/core-api/Cargo.toml +1 -0
  61. package/sdk-core/core-api/src/worker.rs +84 -30
  62. package/sdk-core/sdk/Cargo.toml +1 -2
  63. package/sdk-core/sdk/src/lib.rs +1 -1
  64. package/sdk-core/sdk/src/workflow_context.rs +9 -8
  65. package/sdk-core/sdk/src/workflow_future.rs +19 -14
  66. package/sdk-core/sdk-core-protos/Cargo.toml +2 -0
  67. package/sdk-core/sdk-core-protos/build.rs +6 -1
  68. package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
  69. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3207 -158
  70. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +2934 -118
  71. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/activity/v1/message.proto +67 -0
  72. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +47 -1
  73. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -7
  74. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
  75. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +5 -3
  76. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +3 -3
  77. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +14 -13
  78. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -3
  79. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +22 -0
  80. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +13 -2
  81. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +26 -6
  82. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +5 -0
  83. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +6 -0
  84. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -12
  85. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/update/v1/message.proto +18 -19
  86. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +27 -0
  87. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +192 -19
  88. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +279 -12
  89. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -1
  90. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -1
  91. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -1
  92. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/common/common.proto +1 -1
  93. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +17 -1
  94. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -1
  95. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +1 -1
  96. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +1 -1
  97. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +1 -1
  98. package/sdk-core/sdk-core-protos/src/lib.rs +30 -6
  99. package/sdk-core/test-utils/Cargo.toml +1 -2
  100. package/sdk-core/test-utils/src/lib.rs +2 -2
  101. package/sdk-core/tests/heavy_tests.rs +1 -1
  102. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +2 -2
  103. package/sdk-core/tests/integ_tests/metrics_tests.rs +144 -7
  104. package/sdk-core/tests/integ_tests/queries_tests.rs +1 -1
  105. package/sdk-core/tests/integ_tests/update_tests.rs +109 -5
  106. package/sdk-core/tests/integ_tests/worker_tests.rs +44 -8
  107. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1 -1
  108. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
  109. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +1 -1
  110. package/sdk-core/tests/integ_tests/workflow_tests.rs +3 -2
  111. package/src/conversions/slot_supplier_bridge.rs +287 -0
  112. package/src/conversions.rs +23 -15
  113. package/src/helpers.rs +35 -1
  114. package/src/runtime.rs +7 -3
  115. package/src/worker.rs +1 -1
  116. package/ts/errors.ts +9 -2
  117. package/ts/index.ts +19 -4
  118. package/ts/worker-tuner.ts +123 -1
  119. package/sdk-core/sdk-core-protos/protos/api_upstream/.gitmodules +0 -3
@@ -11,6 +11,24 @@ export interface WorkerTuner {
11
11
  localActivityTaskSlotSupplier: SlotSupplier;
12
12
  }
13
13
 
14
+ export type SlotInfo = WorkflowSlotInfo | ActivitySlotInfo | LocalActivitySlotInfo;
15
+
16
+ export interface WorkflowSlotInfo {
17
+ type: 'workflow';
18
+ workflowId: string;
19
+ runId: string;
20
+ }
21
+
22
+ export interface ActivitySlotInfo {
23
+ type: 'activity';
24
+ activityId: string;
25
+ }
26
+
27
+ export interface LocalActivitySlotInfo {
28
+ type: 'local-activity';
29
+ activityId: string;
30
+ }
31
+
14
32
  /**
15
33
  * Controls how slots are handed out for a specific task type.
16
34
  *
@@ -19,7 +37,7 @@ export interface WorkerTuner {
19
37
  *
20
38
  * @experimental
21
39
  */
22
- export type SlotSupplier = ResourceBasedSlotsForType | FixedSizeSlotSupplier;
40
+ export type SlotSupplier = ResourceBasedSlotsForType | FixedSizeSlotSupplier | CustomSlotSupplier<any>;
23
41
 
24
42
  /**
25
43
  * Options for a specific slot type within a {@link ResourceBasedSlotsForType}
@@ -69,3 +87,107 @@ export interface FixedSizeSlotSupplier {
69
87
  // The maximum number of slots that can be issued
70
88
  numSlots: number;
71
89
  }
90
+
91
+ /**
92
+ * The interface can be implemented to provide custom slot supplier behavior.
93
+ */
94
+ export interface CustomSlotSupplier<SI extends SlotInfo> {
95
+ type: 'custom';
96
+
97
+ /**
98
+ * This function is called before polling for new tasks. Your implementation should block until a
99
+ * slot is available then return a permit to use that slot.
100
+ *
101
+ * The only acceptable exception to throw is AbortError, any other exceptions thrown will be
102
+ * logged and ignored.
103
+ *
104
+ * The value inside the returned promise should be an object, however other types will still count
105
+ * as having issued a permit. Including undefined or null. Returning undefined or null does *not*
106
+ * mean you have not issued a permit. Implementations are expected to block until a meaningful
107
+ * permit can be issued.
108
+ *
109
+ * @param ctx The context for slot reservation.
110
+ * @param abortSignal The SDK may decide to abort the reservation request if it's no longer
111
+ * needed. Implementations may clean up and then must reject the promise with AbortError.
112
+ * @returns A permit to use the slot which may be populated with your own data.
113
+ */
114
+ reserveSlot(ctx: SlotReserveContext, abortSignal: AbortSignal): Promise<SlotPermit>;
115
+
116
+ /**
117
+ * This function is called when trying to reserve slots for "eager" workflow and activity tasks.
118
+ * Eager tasks are those which are returned as a result of completing a workflow task, rather than
119
+ * from polling. Your implementation must not block, and if a slot is available, return a permit
120
+ * to use that slot.
121
+ *
122
+ * @param ctx The context for slot reservation.
123
+ * @returns Maybe a permit to use the slot which may be populated with your own data.
124
+ */
125
+ tryReserveSlot(ctx: SlotReserveContext): SlotPermit | null;
126
+
127
+ /**
128
+ * This function is called once a slot is actually being used to process some task, which may be
129
+ * some time after the slot was reserved originally. For example, if there is no work for a
130
+ * worker, a number of slots equal to the number of active pollers may already be reserved, but
131
+ * none of them are being used yet. This call should be non-blocking.
132
+ *
133
+ * @param ctx The context for marking a slot as used.
134
+ */
135
+ markSlotUsed(slot: SlotMarkUsedContext<SI>): void;
136
+
137
+ /**
138
+ * This function is called once a permit is no longer needed. This could be because the task has
139
+ * finished, whether successfully or not, or because the slot was no longer needed (ex: the number
140
+ * of active pollers decreased). This call should be non-blocking.
141
+ *
142
+ * @param ctx The context for releasing a slot.
143
+ */
144
+ releaseSlot(slot: SlotReleaseContext<SI>): void;
145
+ }
146
+
147
+ export interface SlotPermit {}
148
+
149
+ export interface SlotReserveContext {
150
+ /**
151
+ * The type of slot trying to be reserved
152
+ */
153
+ slotType: SlotInfo['type'];
154
+ /**
155
+ * The name of the task queue for which this reservation request is associated
156
+ */
157
+ taskQueue: string;
158
+ /**
159
+ * The identity of the worker that is requesting the reservation
160
+ */
161
+ workerIdentity: string;
162
+ /**
163
+ * The build id of the worker that is requesting the reservation
164
+ */
165
+ workerBuildId: string;
166
+ /**
167
+ * True iff this is a reservation for a sticky poll for a workflow task
168
+ */
169
+ isSticky: boolean;
170
+ }
171
+
172
+ export interface SlotMarkUsedContext<SI extends SlotInfo> {
173
+ /**
174
+ * Info about the task that will be using the slot
175
+ */
176
+ slotInfo: SI;
177
+ /**
178
+ * The permit that was issued when the slot was reserved
179
+ */
180
+ permit: SlotPermit;
181
+ }
182
+
183
+ export interface SlotReleaseContext<SI extends SlotInfo> {
184
+ /**
185
+ * Info about the task that used this slot, if any. A slot may be released without being used in
186
+ * the event a poll times out.
187
+ */
188
+ slotInfo?: SI;
189
+ /**
190
+ * The permit that was issued when the slot was reserved
191
+ */
192
+ permit: SlotPermit;
193
+ }
@@ -1,3 +0,0 @@
1
- [submodule "proto/api"]
2
- url = ../api
3
- branch = shivam/backlog-count