@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.
- package/Cargo.lock +396 -489
- package/Cargo.toml +3 -2
- package/lib/errors.d.ts +2 -0
- package/lib/errors.js +7 -3
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +8 -2
- package/lib/index.js.map +1 -1
- package/lib/worker-tuner.d.ts +111 -1
- package/package.json +3 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.github/workflows/per-pr.yml +3 -3
- package/sdk-core/Cargo.toml +0 -1
- package/sdk-core/client/Cargo.toml +1 -2
- package/sdk-core/client/src/lib.rs +21 -13
- package/sdk-core/client/src/metrics.rs +1 -1
- package/sdk-core/client/src/raw.rs +46 -1
- package/sdk-core/core/Cargo.toml +7 -7
- package/sdk-core/core/benches/workflow_replay.rs +1 -1
- package/sdk-core/core/src/abstractions/take_cell.rs +1 -1
- package/sdk-core/core/src/abstractions.rs +98 -10
- package/sdk-core/core/src/core_tests/activity_tasks.rs +8 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +1 -1
- package/sdk-core/core/src/core_tests/mod.rs +3 -3
- package/sdk-core/core/src/core_tests/updates.rs +104 -9
- package/sdk-core/core/src/core_tests/workers.rs +72 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +6 -7
- package/sdk-core/core/src/debug_client.rs +78 -0
- package/sdk-core/core/src/ephemeral_server/mod.rs +15 -5
- package/sdk-core/core/src/lib.rs +30 -4
- package/sdk-core/core/src/pollers/mod.rs +1 -1
- package/sdk-core/core/src/pollers/poll_buffer.rs +7 -7
- package/sdk-core/core/src/replay/mod.rs +4 -4
- package/sdk-core/core/src/telemetry/log_export.rs +2 -2
- package/sdk-core/core/src/telemetry/metrics.rs +69 -1
- package/sdk-core/core/src/telemetry/otel.rs +2 -2
- package/sdk-core/core/src/test_help/mod.rs +3 -3
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +3 -3
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +1 -1
- package/sdk-core/core/src/worker/activities/local_activities.rs +68 -24
- package/sdk-core/core/src/worker/activities.rs +26 -15
- package/sdk-core/core/src/worker/client/mocks.rs +10 -4
- package/sdk-core/core/src/worker/client.rs +17 -0
- package/sdk-core/core/src/worker/mod.rs +71 -13
- package/sdk-core/core/src/worker/slot_provider.rs +5 -7
- package/sdk-core/core/src/worker/tuner/fixed_size.rs +4 -3
- package/sdk-core/core/src/worker/tuner/resource_based.rs +171 -32
- package/sdk-core/core/src/worker/tuner.rs +18 -6
- package/sdk-core/core/src/worker/workflow/history_update.rs +43 -13
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +6 -6
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +6 -5
- package/sdk-core/core/src/worker/workflow/managed_run.rs +3 -3
- package/sdk-core/core/src/worker/workflow/mod.rs +13 -7
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +7 -7
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +11 -11
- package/sdk-core/core-api/Cargo.toml +1 -0
- package/sdk-core/core-api/src/worker.rs +84 -30
- package/sdk-core/sdk/Cargo.toml +1 -2
- package/sdk-core/sdk/src/lib.rs +1 -1
- package/sdk-core/sdk/src/workflow_context.rs +9 -8
- package/sdk-core/sdk/src/workflow_future.rs +19 -14
- package/sdk-core/sdk-core-protos/Cargo.toml +2 -0
- package/sdk-core/sdk-core-protos/build.rs +6 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3207 -158
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +2934 -118
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/activity/v1/message.proto +67 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +47 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -7
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +5 -3
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +3 -3
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +14 -13
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -3
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +22 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +13 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +26 -6
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +5 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -12
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/update/v1/message.proto +18 -19
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +27 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +192 -19
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +279 -12
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/common/common.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +17 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +1 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +30 -6
- package/sdk-core/test-utils/Cargo.toml +1 -2
- package/sdk-core/test-utils/src/lib.rs +2 -2
- package/sdk-core/tests/heavy_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +2 -2
- package/sdk-core/tests/integ_tests/metrics_tests.rs +144 -7
- package/sdk-core/tests/integ_tests/queries_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/update_tests.rs +109 -5
- package/sdk-core/tests/integ_tests/worker_tests.rs +44 -8
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests.rs +3 -2
- package/src/conversions/slot_supplier_bridge.rs +287 -0
- package/src/conversions.rs +23 -15
- package/src/helpers.rs +35 -1
- package/src/runtime.rs +7 -3
- package/src/worker.rs +1 -1
- package/ts/errors.ts +9 -2
- package/ts/index.ts +19 -4
- package/ts/worker-tuner.ts +123 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/.gitmodules +0 -3
package/ts/worker-tuner.ts
CHANGED
|
@@ -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
|
+
}
|