@dudousxd/nestjs-durable-core 0.68.0 → 0.69.1
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 +29 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ __export(index_exports, {
|
|
|
32
32
|
DURABLE_STEP_CONFIG: () => DURABLE_STEP_CONFIG,
|
|
33
33
|
DURABLE_STEP_NAME: () => DURABLE_STEP_NAME,
|
|
34
34
|
DurableWorkflow: () => DurableWorkflow,
|
|
35
|
+
ENGINE_MINTED_TAG_PREFIXES: () => ENGINE_MINTED_TAG_PREFIXES,
|
|
35
36
|
EVENT_BUFFER_SCAN_LIMIT: () => EVENT_BUFFER_SCAN_LIMIT,
|
|
36
37
|
EVENT_TOKEN_PREFIX: () => EVENT_TOKEN_PREFIX,
|
|
37
38
|
Entities: () => Entities,
|
|
@@ -98,6 +99,7 @@ __export(index_exports, {
|
|
|
98
99
|
heartbeatStatus: () => heartbeatStatus,
|
|
99
100
|
indexWaitersByRun: () => indexWaitersByRun,
|
|
100
101
|
info: () => info,
|
|
102
|
+
isEngineMintedTag: () => isEngineMintedTag,
|
|
101
103
|
isEventToken: () => isEventToken,
|
|
102
104
|
isLegacyDescriptor: () => isLegacyDescriptor,
|
|
103
105
|
isWorkflowControlFlowSignal: () => isWorkflowControlFlowSignal,
|
|
@@ -4028,6 +4030,15 @@ var WorkflowEngine = class {
|
|
|
4028
4030
|
/**
|
|
4029
4031
|
* Resume each run only if this instance can acquire its recovery lease — so when several
|
|
4030
4032
|
* replicas recover or poll at once, each run is picked up by exactly one of them.
|
|
4033
|
+
*
|
|
4034
|
+
* A run this instance cannot resume is SKIPPED, not allowed to abort the batch. The canonical
|
|
4035
|
+
* case is skew protection: mid-rolling-deploy a pod leases a run whose workflow it does not have
|
|
4036
|
+
* and `resume` throws by design — but the rest of the batch is runs it can drive perfectly well,
|
|
4037
|
+
* and every caller here is a recovery sweep. Letting the first such run end the loop means one
|
|
4038
|
+
* row stops recovery for the whole deployment, and (since the callers are pollers) sends the
|
|
4039
|
+
* rejection into a lifecycle hook. Skipping leaves the run locked only until its lease expires,
|
|
4040
|
+
* for a pod that does have the workflow — which is exactly what the skew-protection error asks
|
|
4041
|
+
* for. Same posture as `publishEvent`'s per-subscriber isolation.
|
|
4031
4042
|
*/
|
|
4032
4043
|
async resumeLeased(runs, nowMs = this.clock(), onLocked) {
|
|
4033
4044
|
if (this.draining) return [];
|
|
@@ -4035,8 +4046,12 @@ var WorkflowEngine = class {
|
|
|
4035
4046
|
for (const run of runs) {
|
|
4036
4047
|
const acquired = await this.store.tryLockRun(run.id, this.instanceId, nowMs + this.leaseMs, nowMs);
|
|
4037
4048
|
if (!acquired) continue;
|
|
4038
|
-
|
|
4039
|
-
|
|
4049
|
+
try {
|
|
4050
|
+
const settled = onLocked ? await onLocked(run) : void 0;
|
|
4051
|
+
results.push(settled ?? await this.resume(run.id));
|
|
4052
|
+
} catch (error2) {
|
|
4053
|
+
console.error(`[nestjs-durable] could not resume run ${run.id} (${run.workflow}@${run.workflowVersion}); leaving it for another instance:`, error2);
|
|
4054
|
+
}
|
|
4040
4055
|
}
|
|
4041
4056
|
return results;
|
|
4042
4057
|
}
|
|
@@ -6142,6 +6157,13 @@ __name(mergeRunFacetRows, "mergeRunFacetRows");
|
|
|
6142
6157
|
// src/run-value-facets.ts
|
|
6143
6158
|
var RUN_VALUE_FACET_LIMIT = 100;
|
|
6144
6159
|
var RUN_VALUE_FACET_SCAN = 5e3;
|
|
6160
|
+
var ENGINE_MINTED_TAG_PREFIXES = [
|
|
6161
|
+
"singleton:"
|
|
6162
|
+
];
|
|
6163
|
+
function isEngineMintedTag(value) {
|
|
6164
|
+
return value !== null && ENGINE_MINTED_TAG_PREFIXES.some((prefix) => value.startsWith(prefix));
|
|
6165
|
+
}
|
|
6166
|
+
__name(isEngineMintedTag, "isEngineMintedTag");
|
|
6145
6167
|
function axisIsRunColumn(axis) {
|
|
6146
6168
|
return axis.field === "workflow" || axis.field === "status" || axis.field === "origin" || axis.field === "namespace";
|
|
6147
6169
|
}
|
|
@@ -6189,6 +6211,9 @@ function mergeRunValueFacetRows(rows, opts) {
|
|
|
6189
6211
|
value,
|
|
6190
6212
|
count
|
|
6191
6213
|
})).filter((row) => row.count > 0).sort((a, b) => {
|
|
6214
|
+
const engineA = isEngineMintedTag(a.value);
|
|
6215
|
+
const engineB = isEngineMintedTag(b.value);
|
|
6216
|
+
if (engineA !== engineB) return engineA ? 1 : -1;
|
|
6192
6217
|
if (b.count !== a.count) return b.count - a.count;
|
|
6193
6218
|
if (a.value === null) return 1;
|
|
6194
6219
|
if (b.value === null) return -1;
|
|
@@ -7117,6 +7142,7 @@ var InMemoryTransport = class {
|
|
|
7117
7142
|
DURABLE_STEP_CONFIG,
|
|
7118
7143
|
DURABLE_STEP_NAME,
|
|
7119
7144
|
DurableWorkflow,
|
|
7145
|
+
ENGINE_MINTED_TAG_PREFIXES,
|
|
7120
7146
|
EVENT_BUFFER_SCAN_LIMIT,
|
|
7121
7147
|
EVENT_TOKEN_PREFIX,
|
|
7122
7148
|
Entities,
|
|
@@ -7183,6 +7209,7 @@ var InMemoryTransport = class {
|
|
|
7183
7209
|
heartbeatStatus,
|
|
7184
7210
|
indexWaitersByRun,
|
|
7185
7211
|
info,
|
|
7212
|
+
isEngineMintedTag,
|
|
7186
7213
|
isEventToken,
|
|
7187
7214
|
isLegacyDescriptor,
|
|
7188
7215
|
isWorkflowControlFlowSignal,
|