@workflow/core 5.2.3 → 5.4.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.
- package/README.md +27 -0
- package/dist/capabilities.d.ts +2 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +7 -1
- package/dist/classify-error.d.ts.map +1 -1
- package/dist/classify-error.js +3 -2
- package/dist/create-hook.d.ts +15 -0
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +1 -1
- package/dist/events-consumer.d.ts +98 -6
- package/dist/events-consumer.d.ts.map +1 -1
- package/dist/events-consumer.js +198 -13
- package/dist/flushable-stream.js +11 -2
- package/dist/global.d.ts +6 -0
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +65 -35
- package/dist/private.d.ts +41 -2
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +39 -4
- package/dist/replay-payload-cache.d.ts +13 -2
- package/dist/replay-payload-cache.d.ts.map +1 -1
- package/dist/replay-payload-cache.js +20 -10
- package/dist/runtime/after-terminal-write.d.ts +33 -0
- package/dist/runtime/after-terminal-write.d.ts.map +1 -0
- package/dist/runtime/after-terminal-write.js +23 -0
- package/dist/runtime/child-run-completion-notify.d.ts +36 -0
- package/dist/runtime/child-run-completion-notify.d.ts.map +1 -0
- package/dist/runtime/child-run-completion-notify.js +97 -0
- package/dist/runtime/child-run-completion.d.ts +45 -0
- package/dist/runtime/child-run-completion.d.ts.map +1 -0
- package/dist/runtime/child-run-completion.js +192 -0
- package/dist/runtime/constants.d.ts +161 -176
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +194 -273
- package/dist/runtime/delivery.d.ts +270 -0
- package/dist/runtime/delivery.d.ts.map +1 -0
- package/dist/runtime/delivery.js +325 -0
- package/dist/runtime/deployment-guard.d.ts +8 -1
- package/dist/runtime/deployment-guard.d.ts.map +1 -1
- package/dist/runtime/deployment-guard.js +12 -6
- package/dist/runtime/get-port-lazy.d.ts.map +1 -1
- package/dist/runtime/get-port-lazy.js +77 -14
- package/dist/runtime/helpers.d.ts +50 -4
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +88 -10
- package/dist/runtime/hook-creation.d.ts +45 -0
- package/dist/runtime/hook-creation.d.ts.map +1 -0
- package/dist/runtime/hook-creation.js +98 -0
- package/dist/runtime/hook-wake.d.ts +16 -14
- package/dist/runtime/hook-wake.d.ts.map +1 -1
- package/dist/runtime/hook-wake.js +31 -18
- package/dist/runtime/invocations.d.ts.map +1 -1
- package/dist/runtime/invocations.js +9 -3
- package/dist/runtime/out-of-band-observation.d.ts +28 -17
- package/dist/runtime/out-of-band-observation.d.ts.map +1 -1
- package/dist/runtime/out-of-band-observation.js +12 -3
- package/dist/runtime/quickjs-delivery-shared.d.ts +126 -0
- package/dist/runtime/quickjs-delivery-shared.d.ts.map +1 -0
- package/dist/runtime/quickjs-delivery-shared.js +176 -0
- package/dist/runtime/quickjs-log-view.d.ts +17 -0
- package/dist/runtime/quickjs-log-view.d.ts.map +1 -1
- package/dist/runtime/quickjs-log-view.js +31 -1
- package/dist/runtime/quickjs-pending-ops.d.ts +181 -0
- package/dist/runtime/quickjs-pending-ops.d.ts.map +1 -0
- package/dist/runtime/quickjs-pending-ops.js +633 -0
- package/dist/runtime/quickjs-runtime.d.ts +30 -5
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +546 -169
- package/dist/runtime/quickjs-serde.d.ts.map +1 -1
- package/dist/runtime/quickjs-serde.js +96 -5
- package/dist/runtime/replay-budget.d.ts +8 -1
- package/dist/runtime/replay-budget.d.ts.map +1 -1
- package/dist/runtime/replay-budget.js +12 -8
- package/dist/runtime/resume-hook.d.ts +15 -10
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +211 -65
- package/dist/runtime/run-spec-routing.d.ts +52 -0
- package/dist/runtime/run-spec-routing.d.ts.map +1 -0
- package/dist/runtime/run-spec-routing.js +78 -0
- package/dist/runtime/run-spec-version.d.ts +8 -4
- package/dist/runtime/run-spec-version.d.ts.map +1 -1
- package/dist/runtime/run-spec-version.js +11 -7
- package/dist/runtime/run.d.ts +29 -3
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +116 -11
- package/dist/runtime/runs.d.ts +58 -2
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +228 -30
- package/dist/runtime/spec8/constants.d.ts +177 -0
- package/dist/runtime/spec8/constants.d.ts.map +1 -0
- package/dist/runtime/spec8/constants.js +232 -0
- package/dist/runtime/spec8/count-step-started-events.d.ts.map +1 -0
- package/dist/runtime/spec8/count-step-started-events.js +72 -0
- package/dist/runtime/spec8/delivery.d.ts +6 -0
- package/dist/runtime/spec8/delivery.d.ts.map +1 -0
- package/dist/runtime/spec8/delivery.js +4250 -0
- package/dist/runtime/spec8/inline-steps-in-flight.d.ts +58 -0
- package/dist/runtime/spec8/inline-steps-in-flight.d.ts.map +1 -0
- package/dist/runtime/spec8/inline-steps-in-flight.js +104 -0
- package/dist/runtime/spec8/open-hook-wait-state.d.ts.map +1 -0
- package/dist/runtime/spec8/open-hook-wait-state.js +93 -0
- package/dist/runtime/{quickjs-entrypoint.d.ts → spec8/quickjs-entrypoint.d.ts} +0 -20
- package/dist/runtime/spec8/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/spec8/quickjs-entrypoint.js +1779 -0
- package/dist/runtime/{step-executor.d.ts → spec8/step-executor.d.ts} +11 -7
- package/dist/runtime/spec8/step-executor.d.ts.map +1 -0
- package/dist/runtime/spec8/step-executor.js +1134 -0
- package/dist/runtime/{step-ownership.d.ts → spec8/step-ownership.d.ts} +1 -1
- package/dist/runtime/spec8/step-ownership.d.ts.map +1 -0
- package/dist/runtime/spec8/step-ownership.js +114 -0
- package/dist/runtime/spec8/step-single-flight.d.ts +34 -0
- package/dist/runtime/spec8/step-single-flight.d.ts.map +1 -0
- package/dist/runtime/spec8/step-single-flight.js +36 -0
- package/dist/runtime/{suspension-handler.d.ts → spec8/suspension-handler.d.ts} +68 -24
- package/dist/runtime/spec8/suspension-handler.d.ts.map +1 -0
- package/dist/runtime/spec8/suspension-handler.js +1291 -0
- package/dist/runtime/spec9/consume-after-commit.d.ts +33 -0
- package/dist/runtime/spec9/consume-after-commit.d.ts.map +1 -0
- package/dist/runtime/spec9/consume-after-commit.js +13 -0
- package/dist/runtime/spec9/consumed-position.d.ts +38 -0
- package/dist/runtime/spec9/consumed-position.d.ts.map +1 -0
- package/dist/runtime/spec9/consumed-position.js +48 -0
- package/dist/runtime/spec9/creator-rules.d.ts +220 -0
- package/dist/runtime/spec9/creator-rules.d.ts.map +1 -0
- package/dist/runtime/spec9/creator-rules.js +357 -0
- package/dist/runtime/spec9/deadline.d.ts +18 -0
- package/dist/runtime/spec9/deadline.d.ts.map +1 -0
- package/dist/runtime/spec9/deadline.js +27 -0
- package/dist/runtime/spec9/delivery.d.ts +17 -0
- package/dist/runtime/spec9/delivery.d.ts.map +1 -0
- package/dist/runtime/spec9/delivery.js +3837 -0
- package/dist/runtime/spec9/fence-refusals.d.ts +20 -0
- package/dist/runtime/spec9/fence-refusals.d.ts.map +1 -0
- package/dist/runtime/spec9/fence-refusals.js +55 -0
- package/dist/runtime/spec9/in-band-writer.d.ts +275 -0
- package/dist/runtime/spec9/in-band-writer.d.ts.map +1 -0
- package/dist/runtime/spec9/in-band-writer.js +831 -0
- package/dist/runtime/spec9/live-feed.d.ts +151 -0
- package/dist/runtime/spec9/live-feed.d.ts.map +1 -0
- package/dist/runtime/spec9/live-feed.js +311 -0
- package/dist/runtime/spec9/log-state.d.ts +137 -0
- package/dist/runtime/spec9/log-state.d.ts.map +1 -0
- package/dist/runtime/spec9/log-state.js +176 -0
- package/dist/runtime/spec9/quickjs-entrypoint.d.ts +185 -0
- package/dist/runtime/spec9/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/spec9/quickjs-entrypoint.js +2332 -0
- package/dist/runtime/spec9/read-deadline.d.ts +46 -0
- package/dist/runtime/spec9/read-deadline.d.ts.map +1 -0
- package/dist/runtime/spec9/read-deadline.js +88 -0
- package/dist/runtime/spec9/run-ahead.d.ts +65 -0
- package/dist/runtime/spec9/run-ahead.d.ts.map +1 -0
- package/dist/runtime/spec9/run-ahead.js +102 -0
- package/dist/runtime/spec9/step-delivery.d.ts +111 -0
- package/dist/runtime/spec9/step-delivery.d.ts.map +1 -0
- package/dist/runtime/spec9/step-delivery.js +149 -0
- package/dist/runtime/spec9/step-executor.d.ts +217 -0
- package/dist/runtime/spec9/step-executor.d.ts.map +1 -0
- package/dist/runtime/spec9/step-executor.js +782 -0
- package/dist/runtime/spec9/step-handler.d.ts +92 -0
- package/dist/runtime/spec9/step-handler.d.ts.map +1 -0
- package/dist/runtime/spec9/step-handler.js +375 -0
- package/dist/runtime/spec9/step-message.d.ts +42 -0
- package/dist/runtime/spec9/step-message.d.ts.map +1 -0
- package/dist/runtime/spec9/step-message.js +81 -0
- package/dist/runtime/spec9/step-retention.d.ts +44 -0
- package/dist/runtime/spec9/step-retention.d.ts.map +1 -0
- package/dist/runtime/spec9/step-retention.js +51 -0
- package/dist/runtime/spec9/step-single-flight.d.ts +19 -0
- package/dist/runtime/spec9/step-single-flight.d.ts.map +1 -0
- package/dist/runtime/spec9/step-single-flight.js +24 -0
- package/dist/runtime/spec9/step-wait-creation.d.ts +162 -0
- package/dist/runtime/spec9/step-wait-creation.d.ts.map +1 -0
- package/dist/runtime/spec9/step-wait-creation.js +450 -0
- package/dist/runtime/spec9/suspension-handler.d.ts +125 -0
- package/dist/runtime/spec9/suspension-handler.d.ts.map +1 -0
- package/dist/runtime/spec9/suspension-handler.js +327 -0
- package/dist/runtime/spec9/wait-timer.d.ts +143 -0
- package/dist/runtime/spec9/wait-timer.d.ts.map +1 -0
- package/dist/runtime/spec9/wait-timer.js +173 -0
- package/dist/runtime/start-hook-binding.d.ts +50 -0
- package/dist/runtime/start-hook-binding.d.ts.map +1 -0
- package/dist/runtime/start-hook-binding.js +85 -0
- package/dist/runtime/start-hook-delivery.d.ts +47 -0
- package/dist/runtime/start-hook-delivery.d.ts.map +1 -0
- package/dist/runtime/start-hook-delivery.js +94 -0
- package/dist/runtime/start-hook-holder.d.ts +50 -0
- package/dist/runtime/start-hook-holder.d.ts.map +1 -0
- package/dist/runtime/start-hook-holder.js +149 -0
- package/dist/runtime/start.d.ts +76 -4
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +451 -62
- package/dist/runtime/step-latency.d.ts +3 -3
- package/dist/runtime/step-latency.js +1 -1
- package/dist/runtime/step-single-flight.d.ts +4 -8
- package/dist/runtime/step-single-flight.d.ts.map +1 -1
- package/dist/runtime/step-single-flight.js +23 -36
- package/dist/runtime/step-streams.d.ts +6 -0
- package/dist/runtime/step-streams.d.ts.map +1 -0
- package/dist/runtime/step-streams.js +40 -0
- package/dist/runtime/suspension-hooks.d.ts +84 -0
- package/dist/runtime/suspension-hooks.d.ts.map +1 -0
- package/dist/runtime/suspension-hooks.js +310 -0
- package/dist/runtime/wait-continuation.d.ts +27 -0
- package/dist/runtime/wait-continuation.d.ts.map +1 -1
- package/dist/runtime/wait-continuation.js +27 -2
- package/dist/runtime/world-compatibility.d.ts +22 -3
- package/dist/runtime/world-compatibility.d.ts.map +1 -1
- package/dist/runtime/world-compatibility.js +37 -2
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +2 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +118 -4154
- package/dist/serialization/abort-stream.d.ts +11 -0
- package/dist/serialization/abort-stream.d.ts.map +1 -0
- package/dist/serialization/abort-stream.js +86 -0
- package/dist/serialization/reducers/common-vm.d.ts.map +1 -1
- package/dist/serialization/reducers/common-vm.js +39 -2
- package/dist/serialization/reducers/common.d.ts.map +1 -1
- package/dist/serialization/reducers/common.js +26 -3
- package/dist/serialization/types.d.ts +10 -1
- package/dist/serialization/types.d.ts.map +1 -1
- package/dist/serialization/types.js +1 -1
- package/dist/serialization.d.ts +21 -5
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +136 -79
- package/dist/set-attributes.d.ts.map +1 -1
- package/dist/set-attributes.js +9 -14
- package/dist/step/context-storage.d.ts +2 -0
- package/dist/step/context-storage.d.ts.map +1 -1
- package/dist/step/context-storage.js +1 -1
- package/dist/step.d.ts.map +1 -1
- package/dist/step.js +23 -16
- package/dist/telemetry/semantic-conventions.d.ts +218 -3
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +161 -2
- package/dist/test-support/append-only-world.d.ts +437 -0
- package/dist/test-support/append-only-world.d.ts.map +1 -0
- package/dist/test-support/append-only-world.js +816 -0
- package/dist/test-support/fence-snapshot.d.ts +11 -0
- package/dist/test-support/fence-snapshot.d.ts.map +1 -0
- package/dist/test-support/fence-snapshot.js +12 -0
- package/dist/test-support/load-events.d.ts +8 -0
- package/dist/test-support/load-events.d.ts.map +1 -0
- package/dist/test-support/load-events.js +27 -0
- package/dist/test-support/orchestrator-harness.d.ts +502 -0
- package/dist/test-support/orchestrator-harness.d.ts.map +1 -0
- package/dist/test-support/orchestrator-harness.js +116 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/workflow/abort-controller.d.ts.map +1 -1
- package/dist/workflow/abort-controller.js +7 -5
- package/dist/workflow/hook.d.ts +5 -0
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +83 -19
- package/dist/workflow.d.ts +45 -16
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +111 -50
- package/docs/api-reference/create-hook.mdx +8 -0
- package/docs/api-reference/create-webhook.mdx +1 -1
- package/docs/api-reference/fetch.mdx +2 -0
- package/docs/foundations/errors-and-retries.mdx +6 -0
- package/docs/foundations/hooks.mdx +3 -1
- package/docs/foundations/idempotency.mdx +190 -60
- package/docs/foundations/starting-workflows.mdx +3 -7
- package/docs/how-it-works/event-sourcing.mdx +6 -0
- package/package.json +5 -5
- package/dist/runtime/count-step-started-events.d.ts.map +0 -1
- package/dist/runtime/count-step-started-events.js +0 -72
- package/dist/runtime/open-hook-wait-state.d.ts.map +0 -1
- package/dist/runtime/open-hook-wait-state.js +0 -93
- package/dist/runtime/quickjs-entrypoint.d.ts.map +0 -1
- package/dist/runtime/quickjs-entrypoint.js +0 -2314
- package/dist/runtime/step-executor.d.ts.map +0 -1
- package/dist/runtime/step-executor.js +0 -1156
- package/dist/runtime/step-ownership.d.ts.map +0 -1
- package/dist/runtime/step-ownership.js +0 -114
- package/dist/runtime/suspension-handler.d.ts.map +0 -1
- package/dist/runtime/suspension-handler.js +0 -1562
- /package/dist/runtime/{count-step-started-events.d.ts → spec8/count-step-started-events.d.ts} +0 -0
- /package/dist/runtime/{open-hook-wait-state.d.ts → spec8/open-hook-wait-state.d.ts} +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The execution message of a background step, as both spec 9 engines (the
|
|
3
|
+
* node orchestrator in `delivery.ts` and the QuickJS one in
|
|
4
|
+
* `quickjs-entrypoint.ts`) build and send it: one place for its wire fields,
|
|
5
|
+
* key, retention and batching. Which steps get a message, and when, stays with
|
|
6
|
+
* each engine.
|
|
7
|
+
*/
|
|
8
|
+
import { SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, } from '@workflow/world';
|
|
9
|
+
import { getStepFunction } from '../../private.js';
|
|
10
|
+
import { DEFAULT_STEP_MAX_RETRIES, STEP_DISPATCH_QUEUE_BATCH_SIZE, } from '../constants.js';
|
|
11
|
+
import { queueMessages, runDispatchContext, stepDispatchIdempotencyKey, } from '../helpers.js';
|
|
12
|
+
import { MAX_STEP_MESSAGE_INPUT_BYTES, stepCreatedAtField, } from './log-state.js';
|
|
13
|
+
import { stepMessageRetentionSeconds } from './step-retention.js';
|
|
14
|
+
/**
|
|
15
|
+
* The message and queue options of one step's execution message.
|
|
16
|
+
*
|
|
17
|
+
* The input rides on the message when the run's transport is binary and it
|
|
18
|
+
* fits `MAX_STEP_MESSAGE_INPUT_BYTES`; otherwise the step's invocation reads
|
|
19
|
+
* it back from `stepCreatedEventId`. The key is step-identity-scoped
|
|
20
|
+
* (correlation id and hashed step name, see `stepDispatchIdempotencyKey`), so
|
|
21
|
+
* a re-send of the same step is absorbed and a stale message for a reassigned
|
|
22
|
+
* correlation id is not. The retention covers the step's retries.
|
|
23
|
+
*/
|
|
24
|
+
export function stepDispatchMessage(params) {
|
|
25
|
+
const { run, step, traceCarrier, delaySeconds, hookResumeTiming } = params;
|
|
26
|
+
const carryInput = (run.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT &&
|
|
27
|
+
step.input instanceof Uint8Array &&
|
|
28
|
+
step.input.byteLength <= MAX_STEP_MESSAGE_INPUT_BYTES;
|
|
29
|
+
return {
|
|
30
|
+
message: {
|
|
31
|
+
runId: run.runId,
|
|
32
|
+
stepId: step.correlationId,
|
|
33
|
+
stepName: step.stepName,
|
|
34
|
+
traceCarrier,
|
|
35
|
+
requestedAt: new Date(),
|
|
36
|
+
// Immutable run identity so the consumer can start the step without a
|
|
37
|
+
// blocking runs.get: see RunDispatchContextSchema.
|
|
38
|
+
runContext: runDispatchContext(run),
|
|
39
|
+
...(step.stepCreatedEventId
|
|
40
|
+
? { stepCreatedEventId: step.stepCreatedEventId }
|
|
41
|
+
: {}),
|
|
42
|
+
...stepCreatedAtField(step),
|
|
43
|
+
...(carryInput ? { stepInput: { input: step.input } } : {}),
|
|
44
|
+
...(step.stepAttempt !== undefined && step.stepAttempt > 1
|
|
45
|
+
? { stepAttempt: step.stepAttempt }
|
|
46
|
+
: {}),
|
|
47
|
+
...(step.resent ? { stepResent: true } : {}),
|
|
48
|
+
...(hookResumeTiming ? { hookResumeTiming } : {}),
|
|
49
|
+
},
|
|
50
|
+
opts: {
|
|
51
|
+
idempotencyKey: stepDispatchIdempotencyKey(step.correlationId, step.stepName),
|
|
52
|
+
retentionSeconds: stepMessageRetentionSeconds(getStepFunction(step.stepName)?.maxRetries ?? DEFAULT_STEP_MAX_RETRIES),
|
|
53
|
+
...(delaySeconds !== undefined && delaySeconds > 0
|
|
54
|
+
? { delaySeconds }
|
|
55
|
+
: {}),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sends the messages of `items` (built by `toMessage`, see
|
|
61
|
+
* `stepDispatchMessage`) in parallel queue batches of at most
|
|
62
|
+
* `STEP_DISPATCH_QUEUE_BATCH_SIZE`. Rejects, with the first failed batch's
|
|
63
|
+
* error, once every batch settled; `onBatchSent` is called with the items of
|
|
64
|
+
* each batch that went out, so a caller can account for the sent ones of a
|
|
65
|
+
* failed send.
|
|
66
|
+
*/
|
|
67
|
+
export async function sendStepDispatchMessages(world, queueName, items, toMessage, onBatchSent) {
|
|
68
|
+
if (items.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
const messages = items.map(toMessage);
|
|
71
|
+
const sends = [];
|
|
72
|
+
for (let offset = 0; offset < items.length; offset += STEP_DISPATCH_QUEUE_BATCH_SIZE) {
|
|
73
|
+
const end = offset + STEP_DISPATCH_QUEUE_BATCH_SIZE;
|
|
74
|
+
sends.push(queueMessages(world, queueName, messages.slice(offset, end)).then(() => onBatchSent?.(items.slice(offset, end))));
|
|
75
|
+
}
|
|
76
|
+
const sent = await Promise.allSettled(sends);
|
|
77
|
+
const failed = sent.find((outcome) => outcome.status === 'rejected');
|
|
78
|
+
if (failed)
|
|
79
|
+
throw failed.reason;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RlcC1tZXNzYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3J1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50LmZpbmQoXG4gICAgKG91dGNvbWUpOiBvdXRjb21lIGlzIFByb21pc2VSZWplY3RlZFJlc3VsdCA9PiBvdXRjb21lLnN0YXR1cyA9PT0gJ3JlamVjdGVkJ1xuICApO1xuICBpZiAoZmFpbGVkKSB0aHJvdyBmYWlsZWQucmVhc29uO1xufVxuIl19
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most a step message may live, retries included. Vercel Queues caps
|
|
3
|
+
* retention at 7 days.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MAX_STEP_MESSAGE_RETENTION_SECONDS: number;
|
|
6
|
+
/**
|
|
7
|
+
* Time a step's last retry must leave before its message expires: room for
|
|
8
|
+
* the last attempt's body plus the redelivery delay a queue may add.
|
|
9
|
+
*/
|
|
10
|
+
export declare const STEP_RETRY_EXPIRY_SLACK_SECONDS: number;
|
|
11
|
+
/**
|
|
12
|
+
* Retention for a step's message, in seconds.
|
|
13
|
+
*
|
|
14
|
+
* A step keeps one message for its whole life, so the message has to outlive
|
|
15
|
+
* every retry. The runtime cannot know the span ahead of time (a
|
|
16
|
+
* `RetryableError` names its own `retryAfter`), so a step that may retry gets
|
|
17
|
+
* the queue's maximum, and a step that never retries gets one day.
|
|
18
|
+
* {@link retryOutlivesMessage} covers a span that exceeds even the maximum.
|
|
19
|
+
*
|
|
20
|
+
* A step's message is sent with an idempotency key, and a queue's dedupe
|
|
21
|
+
* window can be shorter than this retention (`QueueOptions.idempotencyKey`):
|
|
22
|
+
* a message can outlive the dedupe of its own key, for example an inline
|
|
23
|
+
* step's retry moved to its own message with a `retryAfter` past the window.
|
|
24
|
+
* A send of the same step after the window closed would make a second
|
|
25
|
+
* message, a second owner of the step's body. The runtime's re-send rule
|
|
26
|
+
* only sends a step again while its last send (its creation, or the
|
|
27
|
+
* `step_retrying` that moved it) is younger than `STEP_RESEND_MAX_AGE_MS`,
|
|
28
|
+
* inside every World's minimum dedupe window, so it never makes one (see
|
|
29
|
+
* `stepsToReenqueue`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function stepMessageRetentionSeconds(maxRetries: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a retry at `retryAtMs` would land after the step's message expires.
|
|
34
|
+
* The step is then failed instead of retried, since a message that expires
|
|
35
|
+
* before its retry strands the step with no outcome.
|
|
36
|
+
*
|
|
37
|
+
* Unknown `createdAt` (a World that does not report it) answers false.
|
|
38
|
+
*/
|
|
39
|
+
export declare function retryOutlivesMessage(params: {
|
|
40
|
+
messageCreatedAt: Date | undefined;
|
|
41
|
+
retentionSeconds: number;
|
|
42
|
+
retryAtMs: number;
|
|
43
|
+
}): boolean;
|
|
44
|
+
//# sourceMappingURL=step-retention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-retention.d.ts","sourceRoot":"","sources":["../../../src/runtime/spec9/step-retention.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,kCAAkC,QAAkB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,+BAA+B,QAAU,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,gBAAgB,EAAE,IAAI,GAAG,SAAS,CAAC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAOV"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Seconds in a day. */
|
|
2
|
+
const DAY_SECONDS = 24 * 60 * 60;
|
|
3
|
+
/**
|
|
4
|
+
* The most a step message may live, retries included. Vercel Queues caps
|
|
5
|
+
* retention at 7 days.
|
|
6
|
+
*/
|
|
7
|
+
export const MAX_STEP_MESSAGE_RETENTION_SECONDS = 7 * DAY_SECONDS;
|
|
8
|
+
/**
|
|
9
|
+
* Time a step's last retry must leave before its message expires: room for
|
|
10
|
+
* the last attempt's body plus the redelivery delay a queue may add.
|
|
11
|
+
*/
|
|
12
|
+
export const STEP_RETRY_EXPIRY_SLACK_SECONDS = 30 * 60;
|
|
13
|
+
/**
|
|
14
|
+
* Retention for a step's message, in seconds.
|
|
15
|
+
*
|
|
16
|
+
* A step keeps one message for its whole life, so the message has to outlive
|
|
17
|
+
* every retry. The runtime cannot know the span ahead of time (a
|
|
18
|
+
* `RetryableError` names its own `retryAfter`), so a step that may retry gets
|
|
19
|
+
* the queue's maximum, and a step that never retries gets one day.
|
|
20
|
+
* {@link retryOutlivesMessage} covers a span that exceeds even the maximum.
|
|
21
|
+
*
|
|
22
|
+
* A step's message is sent with an idempotency key, and a queue's dedupe
|
|
23
|
+
* window can be shorter than this retention (`QueueOptions.idempotencyKey`):
|
|
24
|
+
* a message can outlive the dedupe of its own key, for example an inline
|
|
25
|
+
* step's retry moved to its own message with a `retryAfter` past the window.
|
|
26
|
+
* A send of the same step after the window closed would make a second
|
|
27
|
+
* message, a second owner of the step's body. The runtime's re-send rule
|
|
28
|
+
* only sends a step again while its last send (its creation, or the
|
|
29
|
+
* `step_retrying` that moved it) is younger than `STEP_RESEND_MAX_AGE_MS`,
|
|
30
|
+
* inside every World's minimum dedupe window, so it never makes one (see
|
|
31
|
+
* `stepsToReenqueue`).
|
|
32
|
+
*/
|
|
33
|
+
export function stepMessageRetentionSeconds(maxRetries) {
|
|
34
|
+
return maxRetries > 0 ? MAX_STEP_MESSAGE_RETENTION_SECONDS : DAY_SECONDS;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether a retry at `retryAtMs` would land after the step's message expires.
|
|
38
|
+
* The step is then failed instead of retried, since a message that expires
|
|
39
|
+
* before its retry strands the step with no outcome.
|
|
40
|
+
*
|
|
41
|
+
* Unknown `createdAt` (a World that does not report it) answers false.
|
|
42
|
+
*/
|
|
43
|
+
export function retryOutlivesMessage(params) {
|
|
44
|
+
const { messageCreatedAt, retentionSeconds, retryAtMs } = params;
|
|
45
|
+
if (!messageCreatedAt)
|
|
46
|
+
return false;
|
|
47
|
+
const expiresAtMs = messageCreatedAt.getTime() +
|
|
48
|
+
(retentionSeconds - STEP_RETRY_EXPIRY_SLACK_SECONDS) * 1000;
|
|
49
|
+
return retryAtMs > expiresAtMs;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RlcC1yZXRlbnRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcnVudGltZS9zcGVjOS9zdGVwLXJldGVudGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx3QkFBd0I7QUFDeEIsTUFBTSxXQUFXLEdBQUcsRUFBRSxHQUFHLEVBQUUsR0FBRyxFQUFFLENBQUM7QUFFakM7OztHQUdHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sa0NBQWtDLEdBQUcsQ0FBQyxHQUFHLFdBQVcsQ0FBQztBQUVsRTs7O0dBR0c7QUFDSCxNQUFNLENBQUMsTUFBTSwrQkFBK0IsR0FBRyxFQUFFLEdBQUcsRUFBRSxDQUFDO0FBRXZEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBbUJHO0FBQ0gsTUFBTSxVQUFVLDJCQUEyQixDQUFDLFVBQWtCO0lBQzVELE9BQU8sVUFBVSxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsa0NBQWtDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQztBQUMzRSxDQUFDO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsTUFBTSxVQUFVLG9CQUFvQixDQUFDLE1BSXBDO0lBQ0MsTUFBTSxFQUFFLGdCQUFnQixFQUFFLGdCQUFnQixFQUFFLFNBQVMsRUFBRSxHQUFHLE1BQU0sQ0FBQztJQUNqRSxJQUFJLENBQUM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29sZWFuIHtcbiAgY29uc3QgeyBtZXNzYWdlQ3JlYXRlZEF0LCByZXRlbnRpb25TZWNvbmRzLCByZXRyeUF0TXMgfSA9IHBhcmFtcztcbiAgaWYgKCFtZXNzYWdlQ3JlYXRlZEF0KSByZXR1cm4gZmFsc2U7XG4gIGNvbnN0IGV4cGlyZXNBdE1zID1cbiAgICBtZXNzYWdlQ3JlYXRlZEF0LmdldFRpbWUoKSArXG4gICAgKHJldGVudGlvblNlY29uZHMgLSBTVEVQX1JFVFJZX0VYUElSWV9TTEFDS19TRUNPTkRTKSAqIDEwMDA7XG4gIHJldHVybiByZXRyeUF0TXMgPiBleHBpcmVzQXRNcztcbn1cbiJdfQ==
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StepExecutionResult } from './step-executor.js';
|
|
2
|
+
/** Delay before a delivery that lost the single-flight is redelivered. */
|
|
3
|
+
export declare const STEP_SINGLE_FLIGHT_REDELIVERY_SECONDS = 1;
|
|
4
|
+
/**
|
|
5
|
+
* A step has one queue message, so two executions of one step in one process
|
|
6
|
+
* are two deliveries of that message: the queue redelivered it while the
|
|
7
|
+
* first delivery was still running the body (an event loop stalled past the
|
|
8
|
+
* lease, or a world without an invocation kill bound). The second delivery
|
|
9
|
+
* awaits the first one's settlement and then asks for the same message again
|
|
10
|
+
* after a short delay instead of running the body (a `throttled` result). It
|
|
11
|
+
* never acknowledges on the first one's behalf: the message is acknowledged
|
|
12
|
+
* only once a terminal step event is committed, and the redelivery confirms
|
|
13
|
+
* that from the log.
|
|
14
|
+
*
|
|
15
|
+
* Background step invocations are not fenced; a cross-instance duplicate
|
|
16
|
+
* runs the body twice.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runStepSingleFlight(runId: string, correlationId: string, execute: () => Promise<StepExecutionResult>, logLevel?: 'debug' | 'warn'): Promise<StepExecutionResult>;
|
|
19
|
+
//# sourceMappingURL=step-single-flight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-single-flight.d.ts","sourceRoot":"","sources":["../../../src/runtime/spec9/step-single-flight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,0EAA0E;AAC1E,eAAO,MAAM,qCAAqC,IAAI,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,EAC3C,QAAQ,GAAE,OAAO,GAAG,MAAe,GAClC,OAAO,CAAC,mBAAmB,CAAC,CAW9B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { runSingleFlight } from '../step-single-flight.js';
|
|
2
|
+
/** Delay before a delivery that lost the single-flight is redelivered. */
|
|
3
|
+
export const STEP_SINGLE_FLIGHT_REDELIVERY_SECONDS = 1;
|
|
4
|
+
/**
|
|
5
|
+
* A step has one queue message, so two executions of one step in one process
|
|
6
|
+
* are two deliveries of that message: the queue redelivered it while the
|
|
7
|
+
* first delivery was still running the body (an event loop stalled past the
|
|
8
|
+
* lease, or a world without an invocation kill bound). The second delivery
|
|
9
|
+
* awaits the first one's settlement and then asks for the same message again
|
|
10
|
+
* after a short delay instead of running the body (a `throttled` result). It
|
|
11
|
+
* never acknowledges on the first one's behalf: the message is acknowledged
|
|
12
|
+
* only once a terminal step event is committed, and the redelivery confirms
|
|
13
|
+
* that from the log.
|
|
14
|
+
*
|
|
15
|
+
* Background step invocations are not fenced; a cross-instance duplicate
|
|
16
|
+
* runs the body twice.
|
|
17
|
+
*/
|
|
18
|
+
export function runStepSingleFlight(runId, correlationId, execute, logLevel = 'warn') {
|
|
19
|
+
return runSingleFlight(runId, correlationId, execute, () => ({
|
|
20
|
+
type: 'throttled',
|
|
21
|
+
timeoutSeconds: STEP_SINGLE_FLIGHT_REDELIVERY_SECONDS,
|
|
22
|
+
}), logLevel);
|
|
23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vcnQgZnVuY3Rpb24gcnVuU3RlcFNpbmdsZUZsaWdodChcbiAgcnVuSWQ6IHN0cmluZyxcbiAgY29ycmVsYXRpb25JZDogc3RyaW5nLFxuICBleGVjdXRlOiAoKSA9PiBQcm9taXNlPFN0ZXBFeGVjdXRpb25SZXN1bHQ+LFxuICBsb2dMZXZlbDogJ2RlYnVnJyB8ICd3YXJuJyA9ICd3YXJuJ1xuKTogUHJvbWlzZTxTdGVwRXhlY3V0aW9uUmVzdWx0PiB7XG4gIHJldHVybiBydW5TaW5nbGVGbGlnaHQoXG4gICAgcnVuSWQsXG4gICAgY29ycmVsYXRpb25JZCxcbiAgICBleGVjdXRlLFxuICAgICgpID0+ICh7XG4gICAgICB0eXBlOiAndGhyb3R0bGVkJyxcbiAgICAgIHRpbWVvdXRTZWNvbmRzOiBTVEVQX1NJTkdMRV9GTElHSFRfUkVERUxJVkVSWV9TRUNPTkRTLFxuICAgIH0pLFxuICAgIGxvZ0xldmVsXG4gICk7XG59XG4iXX0=
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { type CreateEventRequest, type Event, type SerializedData, type WorkflowRun } from '@workflow/world';
|
|
2
|
+
import type { WorkflowSuspension } from '../../global.js';
|
|
3
|
+
import type { PayloadKey } from '../../serialization/encryption.js';
|
|
4
|
+
import type { SuspensionSerializationBlocker } from '../delivery.js';
|
|
5
|
+
import type { InBandWriter } from './in-band-writer.js';
|
|
6
|
+
/** A step this suspension created, and how it executes. */
|
|
7
|
+
export interface CreatedStep {
|
|
8
|
+
correlationId: string;
|
|
9
|
+
stepName: string;
|
|
10
|
+
inline: boolean;
|
|
11
|
+
input: SerializedData;
|
|
12
|
+
/**
|
|
13
|
+
* The committed creation: a background step's `step_created`, or an
|
|
14
|
+
* inline step's first `step_started`. Absent only beside
|
|
15
|
+
* {@link startRefusal}.
|
|
16
|
+
*/
|
|
17
|
+
event?: Event;
|
|
18
|
+
/**
|
|
19
|
+
* An inline step's committed first `step_started`, which is also its
|
|
20
|
+
* creation. The executor then writes no start of its own.
|
|
21
|
+
*/
|
|
22
|
+
started?: StartedInBatch;
|
|
23
|
+
/**
|
|
24
|
+
* Why the World refused an inline step's creation-bearing `step_started`
|
|
25
|
+
* (a throttle, a finished run), as the error a single start write would
|
|
26
|
+
* have thrown. The step is not created; the executor acts on the refusal
|
|
27
|
+
* as on its own start's (a throttle defers the run by the World's backoff,
|
|
28
|
+
* and the next delivery creates the step again).
|
|
29
|
+
*/
|
|
30
|
+
startRefusal?: Error;
|
|
31
|
+
}
|
|
32
|
+
/** The `step_started` that created an inline step. */
|
|
33
|
+
export interface StartedInBatch {
|
|
34
|
+
event: Event;
|
|
35
|
+
/** `Date.now()` right before the batch was sent. */
|
|
36
|
+
postSentAtMs: number;
|
|
37
|
+
/** `Date.now()` once the batch returned. */
|
|
38
|
+
completedAtMs: number;
|
|
39
|
+
}
|
|
40
|
+
export interface StepWaitCreationResult {
|
|
41
|
+
createdSteps: CreatedStep[];
|
|
42
|
+
/** Steps finalized as failed because their arguments did not serialize. */
|
|
43
|
+
failedStepCorrelationIds: Set<string>;
|
|
44
|
+
/** The committed `wait_created` events. */
|
|
45
|
+
createdWaits: Event[];
|
|
46
|
+
serializationBlockerCount: number;
|
|
47
|
+
serializationBlockers: SuspensionSerializationBlocker[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Writes the step and wait creations of one suspension through the
|
|
51
|
+
* orchestrator's in-band writer.
|
|
52
|
+
*
|
|
53
|
+
* - Each step's creation records its execution mode, fixed here for good.
|
|
54
|
+
* The first `inlineSlots` new steps are inline (the orchestrator runs them
|
|
55
|
+
* in this process): each is created by its first attempt's `step_started`
|
|
56
|
+
* alone, carrying what a `step_created` carries plus `inline: true`. The
|
|
57
|
+
* rest are background steps: a `step_created` with `inline: false`, and
|
|
58
|
+
* they are enqueued once, right after this commit, and never run inline.
|
|
59
|
+
* - Each background step's `step_created` and each `wait_created` records
|
|
60
|
+
* `creatorMessageId`, the queue message of this delivery: only a
|
|
61
|
+
* redelivery of it re-enqueues a background step or schedules a wait's
|
|
62
|
+
* timer. An inline step's creating start records none.
|
|
63
|
+
* - The events go out as one `createBatch` when the World has one, else one
|
|
64
|
+
* at a time. In-band writes are serialized, so a parallel fan-out of
|
|
65
|
+
* single writes would be refused by the fence.
|
|
66
|
+
* - A step whose arguments fail to serialize is finalized as `step_created`
|
|
67
|
+
* (placeholder input) plus `step_failed`, so the workflow observes the
|
|
68
|
+
* error on the next replay.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createStepsAndWaits(params: StepWaitCreationParams): Promise<StepWaitCreationResult>;
|
|
71
|
+
/**
|
|
72
|
+
* The step and wait creations of one suspension, prepared (inputs
|
|
73
|
+
* serialized, execution modes decided) and not yet written.
|
|
74
|
+
*/
|
|
75
|
+
export interface StepWaitCreationPlan {
|
|
76
|
+
/** The steps the commit creates, with their execution mode. */
|
|
77
|
+
steps: Omit<CreatedStep, 'event'>[];
|
|
78
|
+
/** How many waits the commit creates. */
|
|
79
|
+
waitCount: number;
|
|
80
|
+
/** How many steps failed to serialize; the commit finalizes them. */
|
|
81
|
+
failedCount: number;
|
|
82
|
+
/** Guest-code executions while serializing step inputs. */
|
|
83
|
+
serializationBlockerCount: number;
|
|
84
|
+
/** A sample of those executions, for diagnostics. */
|
|
85
|
+
serializationBlockers: SuspensionSerializationBlocker[];
|
|
86
|
+
/**
|
|
87
|
+
* The events the commit writes, in order: each step's creation (an
|
|
88
|
+
* inline step's `step_started`, a background step's `step_created`), then
|
|
89
|
+
* the waits' `wait_created`. Steps whose input failed to serialize are not
|
|
90
|
+
* among them.
|
|
91
|
+
*/
|
|
92
|
+
events: readonly CreateEventRequest[];
|
|
93
|
+
/** Writes the events. See {@link createStepsAndWaits}. */
|
|
94
|
+
commit(): Promise<StepWaitCreationResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Writes the events as {@link commit} does, and resolves `first` once
|
|
97
|
+
* the first batch and every inline creation committed (inline steps come
|
|
98
|
+
* first in {@link events}), with the steps those batches created. `rest`
|
|
99
|
+
* resolves with the steps the later batches created, once they committed.
|
|
100
|
+
* `queued` resolves once the last batch is queued on the writer (or the
|
|
101
|
+
* commit stopped before it): a write queued after that goes out behind
|
|
102
|
+
* every batch. For a plan with no waits and no step that failed to
|
|
103
|
+
* serialize.
|
|
104
|
+
*
|
|
105
|
+
* `onLaterBatch` is called once per batch after the first, as soon as
|
|
106
|
+
* that batch committed, with the steps it created. A batch that failed
|
|
107
|
+
* is not reported; `rest` rejects with its error.
|
|
108
|
+
*/
|
|
109
|
+
commitInChunks(onLaterBatch?: (result: StepWaitCreationResult) => void): {
|
|
110
|
+
first: Promise<StepWaitCreationResult>;
|
|
111
|
+
rest: Promise<StepWaitCreationResult>;
|
|
112
|
+
queued: Promise<void>;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export interface StepWaitCreationParams {
|
|
116
|
+
suspension: WorkflowSuspension;
|
|
117
|
+
run: WorkflowRun;
|
|
118
|
+
writer: InBandWriter;
|
|
119
|
+
eventCount: () => number | undefined;
|
|
120
|
+
encryptionKey: PayloadKey | undefined;
|
|
121
|
+
compression: boolean;
|
|
122
|
+
creatorMessageId: string;
|
|
123
|
+
inlineSlots: number;
|
|
124
|
+
requestId?: string;
|
|
125
|
+
/** Called with each accepted write, to fold it into the loaded log. */
|
|
126
|
+
onCommitted?: (result: {
|
|
127
|
+
event?: Event;
|
|
128
|
+
events?: Event[];
|
|
129
|
+
hasMore?: boolean;
|
|
130
|
+
}) => void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Prepares one suspension's step and wait creations without writing them. Turbo mode starts inline step bodies from the plan while the
|
|
134
|
+
* commit is in flight; everyone else commits at once
|
|
135
|
+
* ({@link createStepsAndWaits}).
|
|
136
|
+
*/
|
|
137
|
+
export declare function planStepsAndWaits(params: StepWaitCreationParams): Promise<StepWaitCreationPlan>;
|
|
138
|
+
/**
|
|
139
|
+
* Splits a suspension's creations into the batches it writes, one after
|
|
140
|
+
* another, in order: each batch holds up to
|
|
141
|
+
* {@link MAX_IN_BAND_CREATION_BATCH_EVENTS} creations and stays within
|
|
142
|
+
* {@link MAX_IN_BAND_CREATION_BATCH_BYTES} (see {@link creationBatchBytes});
|
|
143
|
+
* a single event over the byte budget still goes out, alone. A suspension of
|
|
144
|
+
* at most {@link MAX_BATCH_EVENTS} creations is therefore one batch unless
|
|
145
|
+
* its payloads overflow the byte budget.
|
|
146
|
+
*
|
|
147
|
+
* The inline steps' creation-bearing starts come first and share the first
|
|
148
|
+
* batch with the background creations behind them. An in-band writer sends
|
|
149
|
+
* one batch at a time, so a batch of their own would put one more round trip
|
|
150
|
+
* in front of every background creation, and of the last branch's start. The
|
|
151
|
+
* trade: the inline bodies start once the larger first batch commits rather
|
|
152
|
+
* than a batch of only their starts. Each step's creation is a single event,
|
|
153
|
+
* so no step's events straddle two batches.
|
|
154
|
+
*/
|
|
155
|
+
export declare function batchChunks(events: CreateEventRequest[]): CreateEventRequest[][];
|
|
156
|
+
/**
|
|
157
|
+
* What one creation counts against {@link MAX_IN_BAND_CREATION_BATCH_BYTES}:
|
|
158
|
+
* the binary payloads on its `eventData` (a step's serialized input) plus
|
|
159
|
+
* {@link CREATION_EVENT_META_ALLOWANCE_BYTES} for the rest of the event.
|
|
160
|
+
*/
|
|
161
|
+
export declare function creationBatchBytes(event: CreateEventRequest): number;
|
|
162
|
+
//# sourceMappingURL=step-wait-creation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-wait-creation.d.ts","sourceRoot":"","sources":["../../../src/runtime/spec9/step-wait-creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACV,KAAK,cAAc,EAEnB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAA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