@dudousxd/nestjs-durable-core 0.96.0 → 0.98.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 +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3121,9 +3121,12 @@ interface Transport {
|
|
|
3121
3121
|
* broker transports that carry the two-tier descriptor advertisement (BullMQ) implement it; a pure
|
|
3122
3122
|
* in-process transport returns nothing, so the engine's routing guard stays disengaged (legacy
|
|
3123
3123
|
* assume-compatible, design §7.7). The engine feeds these into {@link planDispatch} to decide whether
|
|
3124
|
-
* a run can dispatch to `group` or must park `blocked`.
|
|
3124
|
+
* a run can dispatch to `group` or must park `blocked`. A transport may reuse a recent read of its
|
|
3125
|
+
* registry; `opts.fresh` asks it to read again (the engine does before it parks a run `blocked`).
|
|
3125
3126
|
*/
|
|
3126
|
-
readWorkerDescriptors?(group: string
|
|
3127
|
+
readWorkerDescriptors?(group: string, opts?: {
|
|
3128
|
+
fresh?: boolean | undefined;
|
|
3129
|
+
}): Promise<WorkerDescriptor[]>;
|
|
3127
3130
|
/**
|
|
3128
3131
|
* Every live {@link WorkerDescriptor} in the deployment, across all groups — the read behind
|
|
3129
3132
|
* {@link WorkflowEngine.announcedWorkflows}. Optional, same as {@link readWorkerDescriptors}: a
|
|
@@ -3293,6 +3296,20 @@ interface GroupHealth {
|
|
|
3293
3296
|
* leaking the raw queue count.
|
|
3294
3297
|
*/
|
|
3295
3298
|
kind?: 'workflow' | 'step';
|
|
3299
|
+
/**
|
|
3300
|
+
* The broker queue the group's tasks wait on, when it is shared with other groups (the BullMQ
|
|
3301
|
+
* transport's `taskQueues: 'grouped'`). Absent when the group has a queue of its own.
|
|
3302
|
+
*/
|
|
3303
|
+
queue?: string;
|
|
3304
|
+
/** The shared {@link queue}'s depth across every group on it. */
|
|
3305
|
+
queueDepth?: number;
|
|
3306
|
+
/** `depth` was counted from a sample of the shared queue's jobs and may undercount. */
|
|
3307
|
+
depthSampled?: boolean;
|
|
3308
|
+
/**
|
|
3309
|
+
* The part of `depth` still waiting on the group's own (per-handler) queue while it is drained
|
|
3310
|
+
* after a switch to a shared {@link queue}. Not part of `queueDepth`.
|
|
3311
|
+
*/
|
|
3312
|
+
drainingDepth?: number;
|
|
3296
3313
|
}
|
|
3297
3314
|
/**
|
|
3298
3315
|
* The **control plane** — a broadcast pub/sub across ALL engine instances (every pod), separate
|
package/dist/index.d.ts
CHANGED
|
@@ -3121,9 +3121,12 @@ interface Transport {
|
|
|
3121
3121
|
* broker transports that carry the two-tier descriptor advertisement (BullMQ) implement it; a pure
|
|
3122
3122
|
* in-process transport returns nothing, so the engine's routing guard stays disengaged (legacy
|
|
3123
3123
|
* assume-compatible, design §7.7). The engine feeds these into {@link planDispatch} to decide whether
|
|
3124
|
-
* a run can dispatch to `group` or must park `blocked`.
|
|
3124
|
+
* a run can dispatch to `group` or must park `blocked`. A transport may reuse a recent read of its
|
|
3125
|
+
* registry; `opts.fresh` asks it to read again (the engine does before it parks a run `blocked`).
|
|
3125
3126
|
*/
|
|
3126
|
-
readWorkerDescriptors?(group: string
|
|
3127
|
+
readWorkerDescriptors?(group: string, opts?: {
|
|
3128
|
+
fresh?: boolean | undefined;
|
|
3129
|
+
}): Promise<WorkerDescriptor[]>;
|
|
3127
3130
|
/**
|
|
3128
3131
|
* Every live {@link WorkerDescriptor} in the deployment, across all groups — the read behind
|
|
3129
3132
|
* {@link WorkflowEngine.announcedWorkflows}. Optional, same as {@link readWorkerDescriptors}: a
|
|
@@ -3293,6 +3296,20 @@ interface GroupHealth {
|
|
|
3293
3296
|
* leaking the raw queue count.
|
|
3294
3297
|
*/
|
|
3295
3298
|
kind?: 'workflow' | 'step';
|
|
3299
|
+
/**
|
|
3300
|
+
* The broker queue the group's tasks wait on, when it is shared with other groups (the BullMQ
|
|
3301
|
+
* transport's `taskQueues: 'grouped'`). Absent when the group has a queue of its own.
|
|
3302
|
+
*/
|
|
3303
|
+
queue?: string;
|
|
3304
|
+
/** The shared {@link queue}'s depth across every group on it. */
|
|
3305
|
+
queueDepth?: number;
|
|
3306
|
+
/** `depth` was counted from a sample of the shared queue's jobs and may undercount. */
|
|
3307
|
+
depthSampled?: boolean;
|
|
3308
|
+
/**
|
|
3309
|
+
* The part of `depth` still waiting on the group's own (per-handler) queue while it is drained
|
|
3310
|
+
* after a switch to a shared {@link queue}. Not part of `queueDepth`.
|
|
3311
|
+
*/
|
|
3312
|
+
drainingDepth?: number;
|
|
3296
3313
|
}
|
|
3297
3314
|
/**
|
|
3298
3315
|
* The **control plane** — a broadcast pub/sub across ALL engine instances (every pod), separate
|
package/dist/index.js
CHANGED
|
@@ -5007,10 +5007,24 @@ var TransportPool = class {
|
|
|
5007
5007
|
if (transport.groupHealth) reports.push(await transport.groupHealth(group));
|
|
5008
5008
|
}
|
|
5009
5009
|
if (reports.length === 0) return void 0;
|
|
5010
|
+
const shared = reports.find((r) => r.queue !== void 0);
|
|
5011
|
+
const draining = reports.reduce((sum, r) => sum + (r.drainingDepth ?? 0), 0);
|
|
5010
5012
|
return {
|
|
5011
5013
|
group,
|
|
5012
5014
|
depth: reports.reduce((sum, r) => sum + r.depth, 0),
|
|
5013
|
-
liveWorkers: reports.flatMap((r) => r.liveWorkers)
|
|
5015
|
+
liveWorkers: reports.flatMap((r) => r.liveWorkers),
|
|
5016
|
+
...shared?.queue !== void 0 ? {
|
|
5017
|
+
queue: shared.queue
|
|
5018
|
+
} : {},
|
|
5019
|
+
...shared?.queueDepth !== void 0 ? {
|
|
5020
|
+
queueDepth: shared.queueDepth
|
|
5021
|
+
} : {},
|
|
5022
|
+
...reports.some((r) => r.depthSampled) ? {
|
|
5023
|
+
depthSampled: true
|
|
5024
|
+
} : {},
|
|
5025
|
+
...draining > 0 ? {
|
|
5026
|
+
drainingDepth: draining
|
|
5027
|
+
} : {}
|
|
5014
5028
|
};
|
|
5015
5029
|
}
|
|
5016
5030
|
/**
|
|
@@ -5081,11 +5095,11 @@ var TransportPool = class {
|
|
|
5081
5095
|
* but none is published — both are the "guard disengaged / legacy assume-compatible" case, so the
|
|
5082
5096
|
* engine's routing guard treats an empty result identically (design §7.7).
|
|
5083
5097
|
*/
|
|
5084
|
-
async readWorkerDescriptors(group) {
|
|
5098
|
+
async readWorkerDescriptors(group, opts) {
|
|
5085
5099
|
const descriptors = [];
|
|
5086
5100
|
for (const { transport } of this.transports) {
|
|
5087
5101
|
if (transport.readWorkerDescriptors) {
|
|
5088
|
-
descriptors.push(...await transport.readWorkerDescriptors(group));
|
|
5102
|
+
descriptors.push(...await transport.readWorkerDescriptors(group, opts));
|
|
5089
5103
|
}
|
|
5090
5104
|
}
|
|
5091
5105
|
return descriptors;
|
|
@@ -13810,11 +13824,14 @@ ${run.workflowVersion}`;
|
|
|
13810
13824
|
}
|
|
13811
13825
|
/** The live descriptors for `token`, reused for {@link workerDescriptorCacheMs}; one read in flight. */
|
|
13812
13826
|
liveWorkerDescriptors(token, fresh = false) {
|
|
13813
|
-
|
|
13827
|
+
const opts = fresh ? {
|
|
13828
|
+
fresh: true
|
|
13829
|
+
} : void 0;
|
|
13830
|
+
if (this.workerDescriptorCacheMs <= 0) return this.pool.readWorkerDescriptors(token, opts);
|
|
13814
13831
|
const now = Date.now();
|
|
13815
13832
|
const cached = this.descriptorCache.get(token);
|
|
13816
13833
|
if (!fresh && cached && now - cached.at < this.workerDescriptorCacheMs) return cached.read;
|
|
13817
|
-
const read = this.pool.readWorkerDescriptors(token);
|
|
13834
|
+
const read = this.pool.readWorkerDescriptors(token, opts);
|
|
13818
13835
|
const entry = {
|
|
13819
13836
|
at: now,
|
|
13820
13837
|
read
|