@dudousxd/nestjs-durable-core 0.85.11 → 0.85.12
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 +56 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +56 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2628,6 +2628,9 @@ type ControlMessage = {
|
|
|
2628
2628
|
} & ({
|
|
2629
2629
|
kind: 'event';
|
|
2630
2630
|
event: EngineEvent;
|
|
2631
|
+
} | {
|
|
2632
|
+
kind: 'events';
|
|
2633
|
+
events: EngineEvent[];
|
|
2631
2634
|
} | {
|
|
2632
2635
|
kind: 'cancel';
|
|
2633
2636
|
runId: string;
|
|
@@ -5089,6 +5092,16 @@ declare class WorkflowEngine {
|
|
|
5089
5092
|
/** Emit a locally-produced lifecycle event: deliver to subscribers AND broadcast it on the
|
|
5090
5093
|
* control plane so other instances (e.g. a dashboard pod) can live-tail this run. */
|
|
5091
5094
|
private emit;
|
|
5095
|
+
/** Events waiting for the control-plane publish in flight, in emit order (see {@link broadcastEvents}). */
|
|
5096
|
+
private readonly eventsToBroadcast;
|
|
5097
|
+
private broadcastingEvents;
|
|
5098
|
+
/**
|
|
5099
|
+
* Publish the queued events in the order they were emitted. A run's own events go out one per
|
|
5100
|
+
* message, as every instance expects them. Step events (a wide fan emits two per step) that queued
|
|
5101
|
+
* up while a publish was in flight go out together in one `events` message, so a fan of 40,000
|
|
5102
|
+
* steps costs the control plane a few hundred messages to every instance instead of 80,000.
|
|
5103
|
+
*/
|
|
5104
|
+
private broadcastEvents;
|
|
5092
5105
|
/** Deliver an event to local subscribers only (no re-broadcast) — used for both locally-produced
|
|
5093
5106
|
* events and ones received from the control plane, so an event shows up once on every instance. */
|
|
5094
5107
|
private deliver;
|
package/dist/index.d.ts
CHANGED
|
@@ -2628,6 +2628,9 @@ type ControlMessage = {
|
|
|
2628
2628
|
} & ({
|
|
2629
2629
|
kind: 'event';
|
|
2630
2630
|
event: EngineEvent;
|
|
2631
|
+
} | {
|
|
2632
|
+
kind: 'events';
|
|
2633
|
+
events: EngineEvent[];
|
|
2631
2634
|
} | {
|
|
2632
2635
|
kind: 'cancel';
|
|
2633
2636
|
runId: string;
|
|
@@ -5089,6 +5092,16 @@ declare class WorkflowEngine {
|
|
|
5089
5092
|
/** Emit a locally-produced lifecycle event: deliver to subscribers AND broadcast it on the
|
|
5090
5093
|
* control plane so other instances (e.g. a dashboard pod) can live-tail this run. */
|
|
5091
5094
|
private emit;
|
|
5095
|
+
/** Events waiting for the control-plane publish in flight, in emit order (see {@link broadcastEvents}). */
|
|
5096
|
+
private readonly eventsToBroadcast;
|
|
5097
|
+
private broadcastingEvents;
|
|
5098
|
+
/**
|
|
5099
|
+
* Publish the queued events in the order they were emitted. A run's own events go out one per
|
|
5100
|
+
* message, as every instance expects them. Step events (a wide fan emits two per step) that queued
|
|
5101
|
+
* up while a publish was in flight go out together in one `events` message, so a fan of 40,000
|
|
5102
|
+
* steps costs the control plane a few hundred messages to every instance instead of 80,000.
|
|
5103
|
+
*/
|
|
5104
|
+
private broadcastEvents;
|
|
5092
5105
|
/** Deliver an event to local subscribers only (no re-broadcast) — used for both locally-produced
|
|
5093
5106
|
* events and ones received from the control plane, so an event shows up once on every instance. */
|
|
5094
5107
|
private deliver;
|
package/dist/index.js
CHANGED
|
@@ -4814,6 +4814,8 @@ var ANNOUNCED_ROUTES_TTL_MS = 5e3;
|
|
|
4814
4814
|
var VERSION_UNDECLARED_TAG = "version:undeclared";
|
|
4815
4815
|
var versionKey = /* @__PURE__ */ __name((name, version) => `${name}@${version}`, "versionKey");
|
|
4816
4816
|
var STEP_FAN_CHUNK = 200;
|
|
4817
|
+
var STEP_EVENTS_PER_BROADCAST = 500;
|
|
4818
|
+
var isStepEvent = /* @__PURE__ */ __name((event) => event.type.startsWith("step."), "isStepEvent");
|
|
4817
4819
|
var FAN_REREAD_CHUNK = 1e3;
|
|
4818
4820
|
var STEP_FAN_SEND_ROUND = 2e3;
|
|
4819
4821
|
var PARENT_NOTIFY_ATTEMPTS = 4;
|
|
@@ -5284,6 +5286,13 @@ var WorkflowEngine = class {
|
|
|
5284
5286
|
...msg.event,
|
|
5285
5287
|
at: new Date(msg.event.at)
|
|
5286
5288
|
}));
|
|
5289
|
+
} else if (msg.kind === "events") {
|
|
5290
|
+
for (const event of msg.events) {
|
|
5291
|
+
this.deliver(markRemoteEvent({
|
|
5292
|
+
...event,
|
|
5293
|
+
at: new Date(event.at)
|
|
5294
|
+
}));
|
|
5295
|
+
}
|
|
5287
5296
|
} else if (msg.kind === "cancel") {
|
|
5288
5297
|
this.notifyCancelled(msg.runId);
|
|
5289
5298
|
} else if (msg.kind === "enqueued") {
|
|
@@ -5865,13 +5874,53 @@ var WorkflowEngine = class {
|
|
|
5865
5874
|
at: /* @__PURE__ */ new Date()
|
|
5866
5875
|
};
|
|
5867
5876
|
this.deliver(full);
|
|
5868
|
-
if (this.controlPlane)
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5877
|
+
if (!this.controlPlane) return;
|
|
5878
|
+
this.eventsToBroadcast.push(full);
|
|
5879
|
+
if (!this.broadcastingEvents) void this.broadcastEvents();
|
|
5880
|
+
}
|
|
5881
|
+
/** Events waiting for the control-plane publish in flight, in emit order (see {@link broadcastEvents}). */
|
|
5882
|
+
eventsToBroadcast = [];
|
|
5883
|
+
broadcastingEvents = false;
|
|
5884
|
+
/**
|
|
5885
|
+
* Publish the queued events in the order they were emitted. A run's own events go out one per
|
|
5886
|
+
* message, as every instance expects them. Step events (a wide fan emits two per step) that queued
|
|
5887
|
+
* up while a publish was in flight go out together in one `events` message, so a fan of 40,000
|
|
5888
|
+
* steps costs the control plane a few hundred messages to every instance instead of 80,000.
|
|
5889
|
+
*/
|
|
5890
|
+
async broadcastEvents() {
|
|
5891
|
+
this.broadcastingEvents = true;
|
|
5892
|
+
try {
|
|
5893
|
+
while (this.eventsToBroadcast.length > 0 && this.controlPlane) {
|
|
5894
|
+
const first = this.eventsToBroadcast[0];
|
|
5895
|
+
let msg;
|
|
5896
|
+
if (isStepEvent(first)) {
|
|
5897
|
+
let n = 1;
|
|
5898
|
+
while (n < STEP_EVENTS_PER_BROADCAST && n < this.eventsToBroadcast.length && isStepEvent(this.eventsToBroadcast[n])) {
|
|
5899
|
+
n += 1;
|
|
5900
|
+
}
|
|
5901
|
+
const events = this.eventsToBroadcast.splice(0, n);
|
|
5902
|
+
msg = events.length === 1 ? {
|
|
5903
|
+
kind: "event",
|
|
5904
|
+
event: first,
|
|
5905
|
+
from: this.instanceId
|
|
5906
|
+
} : {
|
|
5907
|
+
kind: "events",
|
|
5908
|
+
events,
|
|
5909
|
+
from: this.instanceId
|
|
5910
|
+
};
|
|
5911
|
+
} else {
|
|
5912
|
+
this.eventsToBroadcast.shift();
|
|
5913
|
+
msg = {
|
|
5914
|
+
kind: "event",
|
|
5915
|
+
event: first,
|
|
5916
|
+
from: this.instanceId
|
|
5917
|
+
};
|
|
5918
|
+
}
|
|
5919
|
+
await this.controlPlane.publishControl(msg).catch(() => {
|
|
5920
|
+
});
|
|
5921
|
+
}
|
|
5922
|
+
} finally {
|
|
5923
|
+
this.broadcastingEvents = false;
|
|
5875
5924
|
}
|
|
5876
5925
|
}
|
|
5877
5926
|
/** Deliver an event to local subscribers only (no re-broadcast) — used for both locally-produced
|