@dudousxd/nestjs-durable-core 0.80.0 → 0.81.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/dist/index.cjs +400 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +167 -8
- package/dist/index.d.ts +167 -8
- package/dist/index.js +392 -100
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1150,6 +1150,16 @@ interface StepError {
|
|
|
1150
1150
|
retryable?: boolean | undefined;
|
|
1151
1151
|
stack?: string | undefined;
|
|
1152
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* See {@link StateStore.listOrphanedRuns}: the live leases a rebooted engine instance may take back
|
|
1155
|
+
* immediately, i.e. those its previous incarnation (same `instanceId`) held when it died.
|
|
1156
|
+
*/
|
|
1157
|
+
interface OwnedLeaseReclaim {
|
|
1158
|
+
/** The engine instance id the lease must be held by. */
|
|
1159
|
+
owner: string;
|
|
1160
|
+
/** Only leases expiring strictly before this epoch ms (the caller's boot time + `leaseMs`). */
|
|
1161
|
+
lockedBefore: number;
|
|
1162
|
+
}
|
|
1153
1163
|
interface StateStore {
|
|
1154
1164
|
/**
|
|
1155
1165
|
* Provision the tables/collections this store needs, idempotently. Called on boot when the
|
|
@@ -1251,8 +1261,16 @@ interface StateStore {
|
|
|
1251
1261
|
* Optional but recommended: without it the engine lists every incomplete run and filters the
|
|
1252
1262
|
* leases in process, which on a busy fleet reads every healthy running run once per tick per
|
|
1253
1263
|
* worker.
|
|
1254
|
-
|
|
1255
|
-
|
|
1264
|
+
*
|
|
1265
|
+
* When `ownedBy` is given, ALSO return the runs whose lease is still live but held by
|
|
1266
|
+
* `ownedBy.owner` with `lockedUntil < ownedBy.lockedBefore` (strictly), under the same status,
|
|
1267
|
+
* namespace, order and `limit`. The engine passes its own `instanceId` and its boot time plus
|
|
1268
|
+
* `leaseMs`: a lease that expires before then was taken by a PREVIOUS process with the same stable
|
|
1269
|
+
* `instanceId` (one killed without a graceful shutdown), never by this one, so it reclaims those
|
|
1270
|
+
* at once instead of waiting out the lease. A store that ignores the argument keeps the plain
|
|
1271
|
+
* behaviour: those runs are reclaimed once their lease expires.
|
|
1272
|
+
*/
|
|
1273
|
+
listOrphanedRuns?(nowMs: number, limit: number, namespace?: string, ownedBy?: OwnedLeaseReclaim): Promise<WorkflowRun[]>;
|
|
1256
1274
|
/** The oldest `pending` runs awaiting dispatch (FIFO, by `createdAt`), capped at `limit`. */
|
|
1257
1275
|
listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
1258
1276
|
/**
|
|
@@ -1568,6 +1586,13 @@ interface ScheduleQuery {
|
|
|
1568
1586
|
/** The terminal run statuses — a run in one of these is finished and will never change on its own.
|
|
1569
1587
|
* Only these are eligible for retention pruning (a {@link RetentionPolicy} targeting a non-terminal
|
|
1570
1588
|
* status would race the engine and delete live work). */
|
|
1589
|
+
/**
|
|
1590
|
+
* Normalise a namespace to the worker pool it names: `''` is the default pool, exactly like
|
|
1591
|
+
* `'default'` (the transport already maps both to the bare token), so it is stamped, polled and
|
|
1592
|
+
* compared as `'default'`. `undefined` passes through untouched: an UNSET engine namespace is the
|
|
1593
|
+
* operator (drives every namespace), and an unset run namespace belongs to everyone.
|
|
1594
|
+
*/
|
|
1595
|
+
declare function poolNamespace(namespace: string | undefined): string | undefined;
|
|
1571
1596
|
declare const TERMINAL_RUN_STATUSES: readonly RunStatus[];
|
|
1572
1597
|
/**
|
|
1573
1598
|
* One retention rule for hard-pruning terminal run history. Within `statuses` (terminal only), a run
|
|
@@ -3218,6 +3243,20 @@ interface EntityHost {
|
|
|
3218
3243
|
getEvent<T>(runId: string, key: string): Promise<T | undefined>;
|
|
3219
3244
|
signal(token: string, payload: unknown): Promise<unknown>;
|
|
3220
3245
|
}
|
|
3246
|
+
/**
|
|
3247
|
+
* What a workflow-side send needs on top of {@link EntityHost}: a durable buffer write it can AWAIT
|
|
3248
|
+
* inside its turn, and a way to wake an entity run that is parked on its wait. Optional so a bare
|
|
3249
|
+
* {@link EntityHost} (tests, older hosts) still works through {@link Entities.dispatch}.
|
|
3250
|
+
*/
|
|
3251
|
+
interface EntityWorkflowHost {
|
|
3252
|
+
/** Durably buffer `payload` on `token` (the store's `bufferSignal`). */
|
|
3253
|
+
bufferSignal(token: string, payload: unknown): Promise<void>;
|
|
3254
|
+
/** If a run is parked on `token`, wake it with `payload`; if none is, do nothing (no buffering). */
|
|
3255
|
+
wakeWaiter(token: string, payload: unknown): Promise<unknown>;
|
|
3256
|
+
/** Start `runId` of `workflow` if it doesn't exist yet (idempotent by run id). */
|
|
3257
|
+
ensureStarted(workflow: string, input: unknown, runId: string): Promise<unknown>;
|
|
3258
|
+
}
|
|
3259
|
+
declare const ENTITY_WORKFLOW = "__entity";
|
|
3221
3260
|
/**
|
|
3222
3261
|
* Durable keyed **entities** (virtual objects): a keyed actor whose handlers run **serialized per
|
|
3223
3262
|
* key** over **durable state**, exactly once. Each key is one long-lived run (`entity:<name>:<key>`)
|
|
@@ -3226,14 +3265,35 @@ interface EntityHost {
|
|
|
3226
3265
|
*/
|
|
3227
3266
|
declare class Entities {
|
|
3228
3267
|
private readonly host;
|
|
3268
|
+
private readonly workflowHost?;
|
|
3229
3269
|
private readonly configs;
|
|
3230
|
-
constructor(host: EntityHost);
|
|
3270
|
+
constructor(host: EntityHost, workflowHost?: EntityWorkflowHost | undefined);
|
|
3231
3271
|
register<S>(name: string, config: EntityConfig<S>): void;
|
|
3232
3272
|
/** Deliver an op to an entity's runner, starting it on first contact. `reply` (a signal token)
|
|
3233
3273
|
* receives the handler's result, for `ctx.callEntity`. */
|
|
3234
3274
|
dispatch(name: string, key: string, op: string, arg: unknown, reply?: string): Promise<{
|
|
3235
3275
|
runId: string;
|
|
3236
3276
|
}>;
|
|
3277
|
+
/**
|
|
3278
|
+
* The durable half of a send from INSIDE a workflow (`ctx.callEntity` / `ctx.signalEntity`): write
|
|
3279
|
+
* the op to the entity's signal buffer and return once it is stored, so the caller can checkpoint
|
|
3280
|
+
* after it. The op carries `id`, the caller's stable `<runId>:<seq>`, so if the caller dies between
|
|
3281
|
+
* this write and its checkpoint and sends again on replay, the entity skips the second copy. The
|
|
3282
|
+
* entity's run is also ensured here, awaited (`start` only enqueues, it never runs the body
|
|
3283
|
+
* inline), so an op sent on first contact can't be stranded in a buffer no run will ever read if
|
|
3284
|
+
* the process dies right after. The wake-up ({@link kick}) is separate and may be lost: a busy
|
|
3285
|
+
* entity reads the buffer at its next wait, and a parked one is paired with it by the engine's
|
|
3286
|
+
* `reconcileMs` sweep. Returns `false` on a host without a workflow host.
|
|
3287
|
+
*/
|
|
3288
|
+
enqueue(name: string, key: string, op: string, arg: unknown, id: string, reply?: string): Promise<boolean>;
|
|
3289
|
+
/**
|
|
3290
|
+
* Make the entity act on what {@link enqueue} buffered: wake its run if it is parked on its wait
|
|
3291
|
+
* (the run itself was ensured by `enqueue`; ensured again here, idempotently, for a caller replay
|
|
3292
|
+
* that only re-kicks). A run that is busy needs nothing: its next wait reads the buffer before
|
|
3293
|
+
* suspending. The wake carries a no-op `nudge`, never the op itself, so the op stays in
|
|
3294
|
+
* the buffer in arrival order and a lost or repeated kick costs at most one empty iteration.
|
|
3295
|
+
*/
|
|
3296
|
+
kick(name: string, key: string): Promise<void>;
|
|
3237
3297
|
signal(name: string, key: string, op: string, arg?: unknown): Promise<void>;
|
|
3238
3298
|
getState<S = unknown>(name: string, key: string): Promise<S | undefined>;
|
|
3239
3299
|
/** The built-in runner: one long-lived run per key, processing ops serially over state. */
|
|
@@ -4241,6 +4301,12 @@ declare class WorkflowEngine {
|
|
|
4241
4301
|
private readonly instanceId;
|
|
4242
4302
|
private readonly namespace;
|
|
4243
4303
|
private readonly leaseMs;
|
|
4304
|
+
/**
|
|
4305
|
+
* Leases held by this `instanceId` that expire strictly before this epoch ms were taken by a
|
|
4306
|
+
* PREVIOUS process with the same id (every lease this one takes or renews expires at
|
|
4307
|
+
* `clock() + leaseMs`, so at or after it). See {@link orphanedRuns}.
|
|
4308
|
+
*/
|
|
4309
|
+
private readonly ownLeaseCutoffMs;
|
|
4244
4310
|
private readonly maxRecoveryAttempts?;
|
|
4245
4311
|
private readonly remoteAdvanceSilenceMs?;
|
|
4246
4312
|
private readonly reconcileMs;
|
|
@@ -4677,6 +4743,15 @@ declare class WorkflowEngine {
|
|
|
4677
4743
|
* `execution_timeout` error (terminal, so a late step result can't resurrect it), AND its children
|
|
4678
4744
|
* are cascaded exactly as an explicit {@link cancel} cascades them.
|
|
4679
4745
|
*
|
|
4746
|
+
* WHICH RUNS. Every run not yet finished, counted from `createdAt`: `pending` and `blocked` as well
|
|
4747
|
+
* as `running` and `suspended`. A run nobody picks up (no worker on its queue) or nobody can run (no
|
|
4748
|
+
* worker with its capabilities) is as stuck as one that hangs mid-body, and the cap is the backstop
|
|
4749
|
+
* for exactly that — leaving them out meant a run that never started lived forever while one that
|
|
4750
|
+
* started and hung was cut off. Cancelling one a worker is picking up at that moment is safe: the
|
|
4751
|
+
* worker's settle only writes over a live status ({@link SETTLE_ELIGIBLE_STATUSES}), so it can't
|
|
4752
|
+
* bring the run back. `cancelling` is left alone on purpose — a compensating cancel's saga undo is
|
|
4753
|
+
* running, it ends `cancelled` by itself, and cutting it short would skip the undo.
|
|
4754
|
+
*
|
|
4680
4755
|
* WHY THE TERMINAL WRITE IS DIRECT, not a call to {@link cancel}. Two reasons, both still standing:
|
|
4681
4756
|
* the run must land with the `execution_timeout` error `cancel` knows nothing about (`cancel` writes
|
|
4682
4757
|
* a plain `cancelled`, and the code is what a dashboard/alert distinguishes a timeout by), and this
|
|
@@ -4689,8 +4764,8 @@ declare class WorkflowEngine {
|
|
|
4689
4764
|
* children kept running with the parent gone and nothing pointing at them — a silent orphan you
|
|
4690
4765
|
* could only find by reading the runs table by hand. {@link cancelChildren} is the SAME recursive
|
|
4691
4766
|
* walk `cancel` uses, so children of children go too, and it inherits that path's two guards:
|
|
4692
|
-
* `cancel` returns early on a run that is already
|
|
4693
|
-
*
|
|
4767
|
+
* `cancel` returns early on a run that is already terminal (a child that beat the sweep to the
|
|
4768
|
+
* finish is never clobbered, and a re-cancel is a no-op), and it writes the
|
|
4694
4769
|
* parent's terminal status BEFORE recursing, so a cyclic parent→child graph terminates on the
|
|
4695
4770
|
* second visit instead of looping. Two pollers sweeping the same run concurrently therefore write
|
|
4696
4771
|
* the same terminal state twice and cascade into already-cancelled children — idempotent, not
|
|
@@ -4707,6 +4782,27 @@ declare class WorkflowEngine {
|
|
|
4707
4782
|
* replay from their checkpoints, so only the work that had not finished runs again.
|
|
4708
4783
|
*/
|
|
4709
4784
|
recoverIncomplete(nowMs?: number): Promise<RunResult[]>;
|
|
4785
|
+
/** A run whose still-live lease is held by this very `instanceId` (see {@link reclaimOwnLease}). */
|
|
4786
|
+
private isOwnLiveLease;
|
|
4787
|
+
/**
|
|
4788
|
+
* Recover a run whose lease is still live but held by THIS `instanceId` and predates this process
|
|
4789
|
+
* (listed by {@link orphanedRuns}): the previous process with this stable id died without a
|
|
4790
|
+
* graceful shutdown (OOM, SIGKILL), so nothing is renewing that lease and waiting for it to expire
|
|
4791
|
+
* only delays the run. The lease is taken back with `renewRunLock` (a compare-and-set on the
|
|
4792
|
+
* owner; `tryLockRun` refuses a live lease), so the lease alone cannot fence a live execution in
|
|
4793
|
+
* THIS process from its own recovery: the in-process run gate does. A run with a
|
|
4794
|
+
* gate is executing (or about to) here and is skipped; otherwise a gate is held while the run is
|
|
4795
|
+
* recovered, so a resume landing meanwhile queues behind the recovery instead of running beside it.
|
|
4796
|
+
* The gate is released before the re-dispatch, which may resume the run on this instance.
|
|
4797
|
+
*/
|
|
4798
|
+
private reclaimOwnLease;
|
|
4799
|
+
/**
|
|
4800
|
+
* One run of a {@link recoverIncomplete} pass: take its lease and decide on it. Resolves the
|
|
4801
|
+
* pass's result for it and whether it must be re-dispatched, or `undefined` when it was not ours.
|
|
4802
|
+
* `ownLease`: the run's live lease is this instance id's own, left by a previous process (see
|
|
4803
|
+
* {@link reclaimOwnLease}), so it is taken back by owner rather than acquired as a free one.
|
|
4804
|
+
*/
|
|
4805
|
+
private recoverOrphan;
|
|
4710
4806
|
/**
|
|
4711
4807
|
* The runs {@link recoverIncomplete} should try to reclaim: incomplete runs whose lease is free or
|
|
4712
4808
|
* expired, never the healthy ones a live turn is renewing. Every worker runs recovery on every
|
|
@@ -4715,6 +4811,10 @@ declare class WorkflowEngine {
|
|
|
4715
4811
|
* ({@link StateStore.listOrphanedRuns}, bounded by {@link RECOVERY_BATCH}); else the full list is
|
|
4716
4812
|
* filtered here, which still spares the probes. Shuffled, like the due-timer pass, so instances
|
|
4717
4813
|
* recovering at once spread over the batch instead of contending for the same leases.
|
|
4814
|
+
*
|
|
4815
|
+
* Also listed: runs still leased by THIS `instanceId` with a lease taken before this process
|
|
4816
|
+
* booted ({@link ownLeaseCutoffMs}). With a stable `instanceId` (pinned to the pod identity), that
|
|
4817
|
+
* is the previous process, killed without a graceful shutdown; see {@link reclaimOwnLease}.
|
|
4718
4818
|
*/
|
|
4719
4819
|
private orphanedRuns;
|
|
4720
4820
|
/**
|
|
@@ -4947,6 +5047,13 @@ declare class WorkflowEngine {
|
|
|
4947
5047
|
* side actually removes the row is the one that delivers, so a signal is never delivered twice.
|
|
4948
5048
|
*/
|
|
4949
5049
|
signal(token: string, payload: unknown): Promise<RunResult | null>;
|
|
5050
|
+
/**
|
|
5051
|
+
* Wake the run parked on `token` with `payload`, if there is one; otherwise do nothing — unlike
|
|
5052
|
+
* {@link signal}, it never buffers. For a wake-up whose real payload is ALREADY buffered on the
|
|
5053
|
+
* token (an entity op, see `Entities.kick`): a run that isn't parked reads that buffer at its next
|
|
5054
|
+
* wait, so there is nothing to keep.
|
|
5055
|
+
*/
|
|
5056
|
+
private wakeSignalWaiter;
|
|
4950
5057
|
/**
|
|
4951
5058
|
* Ensure a run exists for `runId`, then deliver a signal to it — atomically race-free thanks to
|
|
4952
5059
|
* signal buffering: if the run is new (or busy / not yet waiting), the signal is buffered and
|
|
@@ -5165,6 +5272,13 @@ declare class WorkflowEngine {
|
|
|
5165
5272
|
/** Checkpoint a step that failed terminally, so the failure point is visible (not just the run). */
|
|
5166
5273
|
private failStep;
|
|
5167
5274
|
/** Admission persists the wait atomically; never overwrite a cancellation after it returns. */
|
|
5275
|
+
/**
|
|
5276
|
+
* A run's first execution: `pending` -> `running`. A singleton run not yet admitted is stamped
|
|
5277
|
+
* {@link SINGLETON_TRACKED_TAG} in the same write, BEFORE it competes for a slot, so a run this
|
|
5278
|
+
* replica is about to admit or deny is never mistaken for a holder admitted by a replica older
|
|
5279
|
+
* than 0.73 (see `legacySingletonHolders`).
|
|
5280
|
+
*/
|
|
5281
|
+
private markStarted;
|
|
5168
5282
|
private singletonWaitResult;
|
|
5169
5283
|
private execute;
|
|
5170
5284
|
/**
|
|
@@ -6086,6 +6200,15 @@ declare function fanPageEtag(group: string, stats: CheckpointStat[], query: FanP
|
|
|
6086
6200
|
/** Whether an `If-None-Match` header value names `etag` (weak comparison, as RFC 9110 asks for). */
|
|
6087
6201
|
declare function etagMatches(ifNoneMatch: string | undefined, etag: string): boolean;
|
|
6088
6202
|
|
|
6203
|
+
/**
|
|
6204
|
+
* Split a `ctx.webhook()` token (`wh:<runId>:<seq>`) into its run id and logical position, or `null`
|
|
6205
|
+
* for any other token. The run id may itself contain `:` (an entity run is `entity:<name>:<key>`), so
|
|
6206
|
+
* the seq is the LAST segment.
|
|
6207
|
+
*/
|
|
6208
|
+
declare function parseWebhookToken(token: string): {
|
|
6209
|
+
runId: string;
|
|
6210
|
+
seq: number;
|
|
6211
|
+
} | null;
|
|
6089
6212
|
/**
|
|
6090
6213
|
* Resolve WHAT a suspended run is parked on from the token of the {@link SignalWaiter} it registered.
|
|
6091
6214
|
* The token prefix carries the kind — no extra store lookup and no new persisted field. Used by the
|
|
@@ -6166,7 +6289,7 @@ declare class CodecStateStore implements StateStore {
|
|
|
6166
6289
|
readonly deleteRuns?: (runIds: string[]) => Promise<void>;
|
|
6167
6290
|
/** Decodes the runs like {@link listIncompleteRuns}. Bound only when the inner store has it, so
|
|
6168
6291
|
* the engine's list-and-filter fallback still kicks in through the wrapper. */
|
|
6169
|
-
readonly listOrphanedRuns?: (nowMs: number, limit: number, namespace?: string) => Promise<WorkflowRun[]>;
|
|
6292
|
+
readonly listOrphanedRuns?: (nowMs: number, limit: number, namespace?: string, ownedBy?: OwnedLeaseReclaim) => Promise<WorkflowRun[]>;
|
|
6170
6293
|
/** Encodes the patch like {@link updateRun}. Bound only when the inner store has it, so the
|
|
6171
6294
|
* engine's read-then-write fallback still kicks in through the wrapper. */
|
|
6172
6295
|
readonly updateRunIf?: (runId: string, expectedStatuses: RunStatus[], patch: Partial<WorkflowRun>) => Promise<boolean>;
|
|
@@ -6669,7 +6792,7 @@ declare class InMemoryStateStore implements StateStore {
|
|
|
6669
6792
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
6670
6793
|
saveCheckpointIfPending(checkpoint: StepCheckpoint): Promise<boolean>;
|
|
6671
6794
|
saveCheckpointsIfPending(checkpoints: StepCheckpoint[]): Promise<boolean[]>;
|
|
6672
|
-
listOrphanedRuns(nowMs: number, limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
6795
|
+
listOrphanedRuns(nowMs: number, limit: number, namespace?: string, ownedBy?: OwnedLeaseReclaim): Promise<WorkflowRun[]>;
|
|
6673
6796
|
listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
|
|
6674
6797
|
listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
6675
6798
|
listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
|
|
@@ -6769,7 +6892,42 @@ declare class InMemoryTransport implements Transport, ControlPlane {
|
|
|
6769
6892
|
|
|
6770
6893
|
/** Reserved engine metadata: a durable singleton slot, independent of the execution lease. */
|
|
6771
6894
|
declare const SINGLETON_ADMITTED_TAG = "durable:singleton:admitted";
|
|
6895
|
+
/**
|
|
6896
|
+
* Reserved engine metadata: this not-yet-admitted run's admission is decided by the tag scheme, so
|
|
6897
|
+
* it holds no slot unless it carries {@link SINGLETON_ADMITTED_TAG}. Stamped on a run's first
|
|
6898
|
+
* execution (`pending` -> `running`) and on every denial. An untagged run WITHOUT it that a
|
|
6899
|
+
* replica has executed was executed by a replica older than 0.73: see
|
|
6900
|
+
* {@link legacySingletonHolders}. Admission and terminal settlement remove it.
|
|
6901
|
+
*/
|
|
6902
|
+
declare const SINGLETON_TRACKED_TAG = "durable:singleton:tracked";
|
|
6903
|
+
/** Tags only the engine/store may write; stripped from user-supplied start tags. */
|
|
6904
|
+
declare const SINGLETON_RESERVED_TAGS: readonly string[];
|
|
6772
6905
|
declare const SINGLETON_ACTIVE_STATUSES: RunStatus[];
|
|
6906
|
+
/** `tags` without the engine's singleton admission metadata. */
|
|
6907
|
+
declare function withoutSingletonMarkers(tags: string[] | undefined): string[] | undefined;
|
|
6908
|
+
/** `tags` carrying {@link SINGLETON_TRACKED_TAG} (unchanged when admitted or already tracked). */
|
|
6909
|
+
declare function withSingletonTracked(tags: string[] | undefined): string[];
|
|
6910
|
+
/**
|
|
6911
|
+
* The runs other than `runId` that may hold a slot of this key WITHOUT carrying
|
|
6912
|
+
* {@link SINGLETON_ADMITTED_TAG}: holders admitted by a replica older than 0.73, during a rolling
|
|
6913
|
+
* upgrade that mixes old and new replicas.
|
|
6914
|
+
*
|
|
6915
|
+
* Old replicas admit by a scan: a run may execute when it is among the `limit` oldest
|
|
6916
|
+
* `running`/`suspended`/`cancelling` runs sharing the key, by `(createdAt, id)`, and they write no
|
|
6917
|
+
* tag. Among those statuses, an untagged run counts as a legacy holder when either:
|
|
6918
|
+
*
|
|
6919
|
+
* - it lacks {@link SINGLETON_TRACKED_TAG}. A new replica stamps that marker on a run's first
|
|
6920
|
+
* execution and on every denial, so an untagged executed run without it was executed (admitted)
|
|
6921
|
+
* by an old replica. A denial alone cannot be told apart from a holder (both old and new denials
|
|
6922
|
+
* park the run `suspended` with a retry `wakeAt`, exactly like a holder sleeping in `ctx.sleep`),
|
|
6923
|
+
* which is why the marker exists. Waiters an old replica parked count too until a new replica
|
|
6924
|
+
* re-checks them (one retry, ~1s), which only delays, never over-admits.
|
|
6925
|
+
* - it sits inside the old scan's own window (the `limit` oldest of those runs). An old replica can
|
|
6926
|
+
* admit a run a new replica had marked, without clearing the marker; the window is what it
|
|
6927
|
+
* admitted it on. Without old replicas this never changes a `limit: 1` decision (a run inside the
|
|
6928
|
+
* window is the head of the FIFO, admitted next anyway); with a larger limit it can only delay one.
|
|
6929
|
+
*/
|
|
6930
|
+
declare function legacySingletonHolders(active: WorkflowRun[], runId: string, limit: number): WorkflowRun[];
|
|
6773
6931
|
/** Call only inside a store's atomic admission transaction/critical section. */
|
|
6774
6932
|
declare function singletonAdmissionTags(runs: WorkflowRun[], runId: string, tag: string, workflow: string, limit: number): string[] | null;
|
|
6775
6933
|
/** Terminal runs release admission, including when later resumed directly rather than requeued. */
|
|
@@ -6778,7 +6936,8 @@ declare function clearTerminalSingletonAdmission(runId: string, patch: Partial<W
|
|
|
6778
6936
|
declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: string, tag: string, workflow: string, retryWakeAt?: number): {
|
|
6779
6937
|
status: 'suspended';
|
|
6780
6938
|
wakeAt: number;
|
|
6939
|
+
tags: string[];
|
|
6781
6940
|
updatedAt: Date;
|
|
6782
6941
|
} | undefined;
|
|
6783
6942
|
|
|
6784
|
-
export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, type Settled, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, fanPageBounds, fanPageEtag, foldedCount, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, listSignalWaitersOfRuns, liveHandoff, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, queryCheckpointsOf, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, retiredHandoffName, routeFor, runDetailEtag, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, useDurableExecution, warn, workflowName };
|
|
6943
|
+
export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OwnedLeaseReclaim, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, type Settled, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, fanPageBounds, fanPageEtag, foldedCount, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, legacySingletonHolders, listSignalWaitersOfRuns, liveHandoff, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, queryCheckpointsOf, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, retiredHandoffName, routeFor, runDetailEtag, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
|