@dudousxd/nestjs-durable-core 0.94.0 → 0.95.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 +64 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.js +64 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5315,6 +5315,24 @@ var TransportPool = class {
|
|
|
5315
5315
|
return stops;
|
|
5316
5316
|
}
|
|
5317
5317
|
/**
|
|
5318
|
+
* The live run-queue consumers ({@link Transport.liveRunConsumers}) across every transport that
|
|
5319
|
+
* reports them, one per instance (its latest beat): an engine consuming the run queue of two
|
|
5320
|
+
* pinned transports is still one process.
|
|
5321
|
+
*/
|
|
5322
|
+
async liveRunConsumers(opts) {
|
|
5323
|
+
const byInstance = /* @__PURE__ */ new Map();
|
|
5324
|
+
for (const { transport } of this.transports) {
|
|
5325
|
+
if (!transport.liveRunConsumers) continue;
|
|
5326
|
+
for (const beat of await transport.liveRunConsumers(opts)) {
|
|
5327
|
+
const seen = byInstance.get(beat.instanceId);
|
|
5328
|
+
if (!seen || beat.lastBeatAt > seen.lastBeatAt) byInstance.set(beat.instanceId, beat);
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
return [
|
|
5332
|
+
...byInstance.values()
|
|
5333
|
+
];
|
|
5334
|
+
}
|
|
5335
|
+
/**
|
|
5318
5336
|
* The live handshake descriptors advertised for `group` (design §7.2), merged across every transport
|
|
5319
5337
|
* that can report them. Returns `[]` when NO transport implements
|
|
5320
5338
|
* {@link Transport.readWorkerDescriptors} (a pure in-process pool) OR when descriptors are supported
|
|
@@ -11784,13 +11802,16 @@ var WorkflowEngine = class _WorkflowEngine {
|
|
|
11784
11802
|
/** Per-group worker health (queue backlog + live worker heartbeats). Covers {@link knownGroups}
|
|
11785
11803
|
* (so a registered group with backlog and ZERO workers still reports — the alert case) UNION the
|
|
11786
11804
|
* groups discovered from live heartbeats (so a local-step group like `pipeline`, not derivable
|
|
11787
|
-
* from registrations, shows once its workers beat)
|
|
11788
|
-
*
|
|
11805
|
+
* from registrations, shows once its workers beat) UNION this engine's in-process workflows while
|
|
11806
|
+
* the run queue has a live consumer (see {@link inProcessWorkflowHealth}). Empty when no transport
|
|
11807
|
+
* can introspect health (only the BullMQ transport implements `groupHealth`). */
|
|
11789
11808
|
async workerHealth(extra = []) {
|
|
11809
|
+
const inProcess = await this.inProcessWorkflowHealth();
|
|
11790
11810
|
const groups = /* @__PURE__ */ new Set([
|
|
11791
11811
|
...this.knownGroups(extra),
|
|
11792
11812
|
...await this.pool.listWorkerGroups(),
|
|
11793
|
-
...await this.inflightStepGroups()
|
|
11813
|
+
...await this.inflightStepGroups(),
|
|
11814
|
+
...inProcess.groups
|
|
11794
11815
|
]);
|
|
11795
11816
|
const workflowTokens = /* @__PURE__ */ new Set();
|
|
11796
11817
|
for (const def of this.workflows.values()) {
|
|
@@ -11803,14 +11824,54 @@ var WorkflowEngine = class _WorkflowEngine {
|
|
|
11803
11824
|
if (!health) continue;
|
|
11804
11825
|
const at = group.lastIndexOf("@");
|
|
11805
11826
|
const baseToken = at === -1 ? group : group.slice(0, at);
|
|
11827
|
+
const consumers = inProcess.groups.has(group) ? inProcess.consumers.filter((c) => !health.liveWorkers.some((w) => w.instanceId === c.instanceId)).map((c) => ({
|
|
11828
|
+
...c,
|
|
11829
|
+
group
|
|
11830
|
+
})) : [];
|
|
11806
11831
|
out.push({
|
|
11807
11832
|
...health,
|
|
11833
|
+
liveWorkers: [
|
|
11834
|
+
...health.liveWorkers,
|
|
11835
|
+
...consumers
|
|
11836
|
+
],
|
|
11808
11837
|
kind: workflowTokens.has(baseToken) ? "workflow" : "step"
|
|
11809
11838
|
});
|
|
11810
11839
|
}
|
|
11811
11840
|
return out;
|
|
11812
11841
|
}
|
|
11813
11842
|
/**
|
|
11843
|
+
* The workflows this deployment executes IN-PROCESS — registered here with a body, so a run of one
|
|
11844
|
+
* is driven by whichever engine instance takes it off the run queue — and the instances consuming
|
|
11845
|
+
* that queue right now. Those instances ARE the workers of these workflows, yet they consume no task
|
|
11846
|
+
* queue and so never wrote a worker heartbeat: a control plane running its own workflows showed
|
|
11847
|
+
* "0 live workers" while it completed runs. Each workflow is reported under the token a worker
|
|
11848
|
+
* serving it would use (`tenantGroup(name, namespace)`), with the run-queue consumers as its live
|
|
11849
|
+
* workers. The engine's internal `__` workflows are left out.
|
|
11850
|
+
*
|
|
11851
|
+
* Nothing when no run-queue consumer is live (a transport that cannot report one, or no driving
|
|
11852
|
+
* instance): the workflows are not served by anything the transport can see, and claiming a worker
|
|
11853
|
+
* for them would hide a starved queue.
|
|
11854
|
+
*/
|
|
11855
|
+
async inProcessWorkflowHealth() {
|
|
11856
|
+
const groups = /* @__PURE__ */ new Set();
|
|
11857
|
+
for (const def of this.workflows.values()) {
|
|
11858
|
+
if (def.remote || def.hasBody === false || def.name.startsWith("__")) continue;
|
|
11859
|
+
groups.add(tenantGroup(sanitizeQueueToken(def.name), this.namespace));
|
|
11860
|
+
}
|
|
11861
|
+
if (groups.size === 0) return {
|
|
11862
|
+
groups,
|
|
11863
|
+
consumers: []
|
|
11864
|
+
};
|
|
11865
|
+
const consumers = await this.pool.liveRunConsumers({
|
|
11866
|
+
namespace: this.namespace
|
|
11867
|
+
}).catch(() => []);
|
|
11868
|
+
if (consumers.length === 0) groups.clear();
|
|
11869
|
+
return {
|
|
11870
|
+
groups,
|
|
11871
|
+
consumers
|
|
11872
|
+
};
|
|
11873
|
+
}
|
|
11874
|
+
/**
|
|
11814
11875
|
* What workflows the LIVE fleet announces it can execute — the deployment-wide registry a picker
|
|
11815
11876
|
* ("call this existing workflow") needs, and the one question this engine's own registry cannot
|
|
11816
11877
|
* answer. {@link workflowBody} answers only for this process, and a missing body is ambiguous: it
|