@dudousxd/nestjs-durable-core 0.85.10 → 0.85.11
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 +44 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +44 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5032,6 +5032,7 @@ var VERSION_UNDECLARED_TAG = "version:undeclared";
|
|
|
5032
5032
|
var versionKey = /* @__PURE__ */ __name((name, version) => `${name}@${version}`, "versionKey");
|
|
5033
5033
|
var STEP_FAN_CHUNK = 200;
|
|
5034
5034
|
var FAN_REREAD_CHUNK = 1e3;
|
|
5035
|
+
var STEP_FAN_SEND_ROUND = 2e3;
|
|
5035
5036
|
var PARENT_NOTIFY_ATTEMPTS = 4;
|
|
5036
5037
|
var PARENT_NOTIFY_BACKOFF_MS = 250;
|
|
5037
5038
|
var LEASE_RECHECK_MAX_MS = 2e3;
|
|
@@ -10442,10 +10443,25 @@ ${run.workflowVersion}`;
|
|
|
10442
10443
|
}
|
|
10443
10444
|
return bySeq;
|
|
10444
10445
|
}
|
|
10446
|
+
/** Write a round of a step fan's checkpoints: one call where the store batches, else chunked. */
|
|
10447
|
+
async saveFanCheckpoints(checkpoints) {
|
|
10448
|
+
if (this.store.saveCheckpoints) {
|
|
10449
|
+
await this.store.saveCheckpoints(checkpoints);
|
|
10450
|
+
return;
|
|
10451
|
+
}
|
|
10452
|
+
for (let at = 0; at < checkpoints.length; at += STEP_FAN_CHUNK) {
|
|
10453
|
+
await Promise.all(checkpoints.slice(at, at + STEP_FAN_CHUNK).map((cp) => this.store.saveCheckpoint(cp)));
|
|
10454
|
+
}
|
|
10455
|
+
}
|
|
10445
10456
|
/**
|
|
10446
|
-
* Write the `pending` checkpoints of a step fan's new steps
|
|
10447
|
-
* {@link
|
|
10448
|
-
*
|
|
10457
|
+
* Write the `pending` checkpoints of a step fan's new steps and dispatch them, in rounds of
|
|
10458
|
+
* {@link STEP_FAN_SEND_ROUND}: a round's steps are dispatched once its checkpoints commit, while the
|
|
10459
|
+
* next round's are written. One {@link StateStore.saveCheckpoints} call and one
|
|
10460
|
+
* {@link TransportPool.dispatchMany} per round, where the store and transport have them.
|
|
10461
|
+
*
|
|
10462
|
+
* No result can wake the run before every round is written: the run is `running` under this
|
|
10463
|
+
* turn's lease until the turn suspends. A send cut short leaves the unwritten steps without a
|
|
10464
|
+
* checkpoint, and the replay sends them once the written ones settle.
|
|
10449
10465
|
*/
|
|
10450
10466
|
async sendStepFan(runId, positions, step, inputs, batch, group, opts, routing) {
|
|
10451
10467
|
const workerGroup = stepGroup(step, routing?.namespace);
|
|
@@ -10473,27 +10489,33 @@ ${run.workflowVersion}`;
|
|
|
10473
10489
|
} : {}
|
|
10474
10490
|
};
|
|
10475
10491
|
});
|
|
10476
|
-
if (this.store.saveCheckpoints) {
|
|
10477
|
-
await this.store.saveCheckpoints(checkpoints);
|
|
10478
|
-
} else {
|
|
10479
|
-
for (let at = 0; at < checkpoints.length; at += STEP_FAN_CHUNK) {
|
|
10480
|
-
await Promise.all(checkpoints.slice(at, at + STEP_FAN_CHUNK).map((cp) => this.store.saveCheckpoint(cp)));
|
|
10481
|
-
}
|
|
10482
|
-
}
|
|
10483
10492
|
const traceparent = this.traceparent?.();
|
|
10484
10493
|
const context = this.context?.();
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10494
|
+
const dispatches = [];
|
|
10495
|
+
try {
|
|
10496
|
+
for (let from = 0; from < checkpoints.length; from += STEP_FAN_SEND_ROUND) {
|
|
10497
|
+
const round = checkpoints.slice(from, from + STEP_FAN_SEND_ROUND);
|
|
10498
|
+
await this.saveFanCheckpoints(round);
|
|
10499
|
+
const dispatch = this.pool.dispatchMany(round.map((cp, k) => ({
|
|
10500
|
+
runId,
|
|
10501
|
+
seq: cp.seq,
|
|
10502
|
+
name: step.name,
|
|
10503
|
+
stepId: cp.stepId,
|
|
10504
|
+
group: workerGroup,
|
|
10505
|
+
input: inputs[batch[from + k]],
|
|
10506
|
+
traceparent,
|
|
10507
|
+
context,
|
|
10508
|
+
priority: opts.admission?.priority,
|
|
10509
|
+
attempt: 1
|
|
10510
|
+
})), opts.transport);
|
|
10511
|
+
dispatch.catch(() => {
|
|
10512
|
+
});
|
|
10513
|
+
dispatches.push(dispatch);
|
|
10514
|
+
}
|
|
10515
|
+
} finally {
|
|
10516
|
+
await Promise.allSettled(dispatches);
|
|
10517
|
+
}
|
|
10518
|
+
await Promise.all(dispatches);
|
|
10497
10519
|
for (const cp of checkpoints) {
|
|
10498
10520
|
this.emit({
|
|
10499
10521
|
type: "step.started",
|