@voltro/workflow 0.86.0 → 0.88.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/CHANGELOG.md +5484 -0
- package/THIRD-PARTY-NOTICES.md +3 -227
- package/dist/admission.js +1 -2
- package/dist/admissionDrainer.js +5 -3
- package/dist/admissionGate.js +1 -2
- package/dist/admissionStore.js +1 -2
- package/dist/admissionSubmission.js +1 -2
- package/dist/admissionTables.js +4 -4
- package/dist/admissionTransaction.js +1 -2
- package/dist/awaitEvent.js +1 -2
- package/dist/budgetHold.js +1 -2
- package/dist/cancelOnPlan.js +1 -2
- package/dist/cancelOnSweep.js +1 -2
- package/dist/cancelPendingStart.js +1 -2
- package/dist/cluster.d.ts +111 -27
- package/dist/cluster.js +12 -8
- package/dist/clusterCron.js +18 -11
- package/dist/clusterDiagnostics.js +1 -2
- package/dist/clusterDiagnosticsSql.js +1 -2
- package/dist/clusterLayer.js +105 -71
- package/dist/clusterMigrationGate.js +1 -2
- package/dist/clusterRunnerLayer.js +27 -18
- package/dist/clusterShardGroups.js +32 -0
- package/dist/clusterTestSuite.d.ts +45 -2
- package/dist/clusterTestSuite.js +225 -197
- package/dist/controlMonitor.js +1 -2
- package/dist/controlRequest.js +1 -2
- package/dist/executionRefusal.js +1 -2
- package/dist/failureHandoff.js +1 -2
- package/dist/failureMessage.js +1 -2
- package/dist/failureRecovery.js +1 -2
- package/dist/failureReportStore.js +1 -2
- package/dist/flowControl.js +1 -2
- package/dist/forwardStartReceipts.js +1 -2
- package/dist/inMemoryLayer.js +1 -2
- package/dist/inMemoryRecorder.js +1 -2
- package/dist/index.d.ts +50 -23
- package/dist/index.js +24 -23
- package/dist/inspectWorkflow.js +2 -3
- package/dist/journalEncryption.js +1 -2
- package/dist/journalRoutingGuard.js +49 -0
- package/dist/journalRoutingLayout.js +46 -0
- package/dist/journalRoutingLock.js +38 -0
- package/dist/journalRoutingMaintenance.js +23 -0
- package/dist/journalRoutingMessageStorage.js +31 -0
- package/dist/journalRoutingNamespace.js +22 -0
- package/dist/journalRoutingRuntime.js +32 -0
- package/dist/journalRoutingSharding.js +27 -0
- package/dist/journalRoutingState.js +92 -0
- package/dist/journalRoutingTable.js +10 -0
- package/dist/journalRoutingTransaction.js +15 -0
- package/dist/messages.js +1 -2
- package/dist/nondeterminism.js +1 -2
- package/dist/parentClosure.js +1 -2
- package/dist/parentClosureRecovery.js +1 -2
- package/dist/pendingSubmission.js +1 -2
- package/dist/prepareSubmissionDispatch.js +1 -2
- package/dist/preparedExecution.js +1 -2
- package/dist/primitives.js +1 -2
- package/dist/queuedCancellationRequest.js +1 -2
- package/dist/queuedControl.js +1 -2
- package/dist/recorder.js +1 -2
- package/dist/residentExecutionEvidence.js +1 -2
- package/dist/retryPolicy.js +1 -2
- package/dist/runEventsTable.js +1 -2
- package/dist/runGeneration.js +1 -2
- package/dist/runRecording.js +1 -2
- package/dist/runStepsTable.js +1 -2
- package/dist/runnerStorageGuard.js +1 -2
- package/dist/runsTable.js +1 -2
- package/dist/scheduleDeclaration.js +1 -2
- package/dist/signalHint.js +1 -2
- package/dist/signals.js +1 -2
- package/dist/signalsSuspending.js +1 -2
- package/dist/sqliteWorkflowOwnership.js +1 -2
- package/dist/stalenessSweep.js +1 -2
- package/dist/startContextsTable.js +1 -2
- package/dist/startReceipt.js +1 -2
- package/dist/submissionRecovery.js +1 -2
- package/dist/submissionRejection.js +1 -2
- package/dist/submissionRetry.js +1 -2
- package/dist/suspensionUnavailable.js +1 -2
- package/dist/updates.js +1 -2
- package/dist/watermarkTable.js +1 -2
- package/dist/webCrypto.js +4 -17
- package/dist/workflowDelivery.js +1 -2
- package/dist/workflowExecutorRouting.js +32 -0
- package/dist/workflowJournal.js +1 -2
- package/dist/workflowJournalReset.js +1 -2
- package/dist/workflowReadSelections.js +1 -2
- package/dist/workflowRestartDispatch.js +30 -25
- package/dist/workflowRestartObservation.js +1 -2
- package/dist/workflowRestartPreparation.js +1 -2
- package/dist/workflowRestartReservation.js +158 -157
- package/dist/workflowResumeDispatch.js +18 -18
- package/dist/workflowRuntimeReadiness.js +11 -0
- package/dist/workflowShardRelocation.js +57 -0
- package/dist/workflowShardRelocationSql.js +71 -0
- package/package.json +5 -11
|
@@ -4,7 +4,7 @@ import { SuspensionUnavailable as i, WorkflowCannotPark as a } from "./suspensio
|
|
|
4
4
|
import { resolveWorkflowMessageRun as o } from "./messages.js";
|
|
5
5
|
import { DurableClock as s, DurableDeferred as c, Workflow as l, WorkflowEngine as u } from "effect/workflow";
|
|
6
6
|
import { Cause as d, Effect as f, Exit as p, Schema as m } from "effect";
|
|
7
|
-
|
|
7
|
+
// src/signalsSuspending.ts
|
|
8
8
|
var h = 864e5, g = "voltro/suspending-signal", _ = (e, t) => `${g}/${e}/${t}`, v = (n, r) => c.make(n, { success: e(r) ? t(m.Unknown, `signal '${n}' value`) : m.Unknown }), y = async (e, t) => {
|
|
9
9
|
if (e) try {
|
|
10
10
|
await e.recordEvent(t);
|
|
@@ -53,5 +53,4 @@ var h = 864e5, g = "voltro/suspending-signal", _ = (e, t) => `${g}/${e}/${t}`, v
|
|
|
53
53
|
exit: p.succeed(e.payload)
|
|
54
54
|
}), { completed: !0 };
|
|
55
55
|
});
|
|
56
|
-
//#endregion
|
|
57
56
|
export { b as awaitSignalSuspending, x as completeSuspendingSignal, _ as suspendingSignalDeferredName };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect as e } from "effect";
|
|
2
2
|
import { realpath as t } from "node:fs/promises";
|
|
3
|
-
|
|
3
|
+
// src/sqliteWorkflowOwnership.ts
|
|
4
4
|
var n = (n) => e.gen(function* () {
|
|
5
5
|
let i = yield* e.tryPromise({
|
|
6
6
|
try: () => t(n),
|
|
@@ -22,5 +22,4 @@ var n = (n) => e.gen(function* () {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
}), r = (e) => e instanceof Error ? e : Error(String(e));
|
|
25
|
-
//#endregion
|
|
26
25
|
export { n as acquireSqliteWorkflowOwnership };
|
package/dist/stalenessSweep.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { and as e, eq as t, gt as n, inSet as r, lt as i, or as a } from "@voltro/database";
|
|
2
|
-
|
|
2
|
+
// src/stalenessSweep.ts
|
|
3
3
|
var o = 18e5, s = 200, c = 20, l = (e) => {
|
|
4
4
|
if (e instanceof Date) return e;
|
|
5
5
|
if (typeof e == "number") return new Date(e);
|
|
@@ -187,5 +187,4 @@ var o = 18e5, s = 200, c = 20, l = (e) => {
|
|
|
187
187
|
...w === void 0 ? {} : { nextRun: w }
|
|
188
188
|
};
|
|
189
189
|
};
|
|
190
|
-
//#endregion
|
|
191
190
|
export { o as DEFAULT_STALL_AFTER_MS, c as DEFAULT_STALL_EVENT_LOOKBACK, s as DEFAULT_STALL_RUN_PAGE, h as sweepStalledRuns };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { id as e, json as t, table as n, text as r, timestamp as i } from "@voltro/database";
|
|
2
|
-
|
|
2
|
+
// src/startContextsTable.ts
|
|
3
3
|
var a = n("_voltro_workflow_start_contexts", {
|
|
4
4
|
id: e({ prefix: "wfctx" }),
|
|
5
5
|
workflowName: r(),
|
|
@@ -16,5 +16,4 @@ var a = n("_voltro_workflow_start_contexts", {
|
|
|
16
16
|
]).nullable(),
|
|
17
17
|
createdAt: i().default("now")
|
|
18
18
|
}).index(["workflowName"]).index(["executionId"]).index(["parentExecutionId"]);
|
|
19
|
-
//#endregion
|
|
20
19
|
export { a as _voltroWorkflowStartContextsTable };
|
package/dist/startReceipt.js
CHANGED
|
@@ -5,7 +5,7 @@ import { PENDING_TABLE as r, toPendingIntent as i } from "./admissionStore.js";
|
|
|
5
5
|
import { Schema as a } from "effect";
|
|
6
6
|
import { WorkflowStartTerminalOutcomeSchema as o } from "@voltro/protocol";
|
|
7
7
|
import { and as s, eq as c, isNull as l } from "@voltro/database";
|
|
8
|
-
|
|
8
|
+
// src/startReceipt.ts
|
|
9
9
|
var u = "_voltro_workflow_start_receipts", d = class extends Error {
|
|
10
10
|
_tag = "WorkflowStartRequestConflictError";
|
|
11
11
|
constructor() {
|
|
@@ -139,5 +139,4 @@ var u = "_voltro_workflow_start_receipts", d = class extends Error {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
//#endregion
|
|
143
142
|
export { u as START_RECEIPTS_TABLE, d as WorkflowStartRequestConflictError, v as bindWorkflowStartReceipts, p as decodeWorkflowStartReceipt, m as readWorkflowStartReceipt, h as readWorkflowStartRequest, _ as recordWorkflowStartReceipt, g as resolveWorkflowStartReceipt, y as settlePendingStartReceipts };
|
|
@@ -4,7 +4,7 @@ import { acknowledgeAdmissionSubmissionInTransaction as n, beginAdmissionSubmiss
|
|
|
4
4
|
import { decodePendingPayload as c, releaseLease as l, retryBackoffMs as u } from "./admissionStore.js";
|
|
5
5
|
import { prepareSubmissionDispatch as d } from "./prepareSubmissionDispatch.js";
|
|
6
6
|
import { Schema as f } from "effect";
|
|
7
|
-
|
|
7
|
+
// src/submissionRecovery.ts
|
|
8
8
|
var p = /* @__PURE__ */ new WeakMap(), m = async (m, h, g, _) => {
|
|
9
9
|
let v = p.get(m), y = await o(m.store, g, v?.afterId), b = 0, x = 0, S = 0, C = 0, w = v?.nextDueAt, T = (e) => {
|
|
10
10
|
w = Math.min(w ?? e, e);
|
|
@@ -118,5 +118,4 @@ var p = /* @__PURE__ */ new WeakMap(), m = async (m, h, g, _) => {
|
|
|
118
118
|
examined: y.length > 0
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
|
-
//#endregion
|
|
122
121
|
export { m as recoverAdmissionSubmissions };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { readWorkflowFailureRecord as e } from "./failureReportStore.js";
|
|
2
|
-
|
|
2
|
+
// src/submissionRejection.ts
|
|
3
3
|
var t = async (t, n) => {
|
|
4
4
|
if (n.failureId === null) throw Error("Workflow submission has no rejection marker");
|
|
5
5
|
let r = await e(t, n.failureId);
|
|
6
6
|
if (n.executionId !== null || n.dispatchAttempts > 1 || r === void 0 || r.sourceKind !== "submission" || r.sourceId !== n.id || r.workflowName !== n.workflowName || r.tenantId !== n.tenantId || r.report.executionId !== null || r.report.runId !== null) throw Error("Workflow start rejection has contradictory ownership or execution evidence");
|
|
7
7
|
return r.id;
|
|
8
8
|
};
|
|
9
|
-
//#endregion
|
|
10
9
|
export { t as readProvenSubmissionRejection };
|
package/dist/submissionRetry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readAdmissionSubmission as e } from "./admissionSubmission.js";
|
|
2
2
|
import { ADMISSIONS_TABLE as t } from "./admissionStore.js";
|
|
3
3
|
import { eq as n } from "@voltro/database";
|
|
4
|
-
|
|
4
|
+
// src/submissionRetry.ts
|
|
5
5
|
var r = (e, t) => ({
|
|
6
6
|
kind: "refused",
|
|
7
7
|
submissionId: e,
|
|
@@ -67,5 +67,4 @@ var r = (e, t) => ({
|
|
|
67
67
|
expected: o
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
-
//#endregion
|
|
71
70
|
export { o as inspectAdmissionSubmissionRetry, s as retryAdmissionSubmissionInTransaction };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Context as e } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/suspensionUnavailable.ts
|
|
3
3
|
var t = e.Reference("@voltro/workflow/SuspensionUnavailable", { defaultValue: () => void 0 }), n = class extends Error {
|
|
4
4
|
constructor(e, t) {
|
|
5
5
|
super(`${e} cannot wait for a durable result here: ${t}`), this.name = "WorkflowCannotPark";
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { t as SuspensionUnavailable, n as WorkflowCannotPark };
|
package/dist/updates.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CurrentWorkflowRunId as r, WorkflowRunRecorder as i } from "./recorder.
|
|
|
4
4
|
import { terminalUpdates as a } from "./workflowReadSelections.js";
|
|
5
5
|
import { Cause as o, Effect as s, Schema as c } from "effect";
|
|
6
6
|
import { eq as l } from "@voltro/database";
|
|
7
|
-
|
|
7
|
+
// src/updates.ts
|
|
8
8
|
var u = async (e, t) => {
|
|
9
9
|
if (e) try {
|
|
10
10
|
await e.recordEvent(t);
|
|
@@ -83,5 +83,4 @@ var u = async (e, t) => {
|
|
|
83
83
|
execute: f
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
-
//#endregion
|
|
87
86
|
export { f as awaitUpdate };
|
package/dist/watermarkTable.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { id as e, table as t, timestamp as n } from "@voltro/database";
|
|
2
|
-
|
|
2
|
+
// src/watermarkTable.ts
|
|
3
3
|
var r = t("_voltro_workflow_watermarks", {
|
|
4
4
|
id: e({ prefix: "wfwm" }),
|
|
5
5
|
positionAt: n(),
|
|
6
6
|
updatedAt: n().default("now")
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { r as _voltroWorkflowWatermarksTable };
|
package/dist/webCrypto.js
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
digest: (e, n) => t.tryPromise({
|
|
6
|
-
try: async () => new Uint8Array(await globalThis.crypto.subtle.digest(e, new Uint8Array(n).buffer)),
|
|
7
|
-
catch: (t) => r.systemError({
|
|
8
|
-
_tag: "Unknown",
|
|
9
|
-
module: "Crypto",
|
|
10
|
-
method: "digest",
|
|
11
|
-
description: `digest ${e} failed`,
|
|
12
|
-
cause: t
|
|
13
|
-
})
|
|
14
|
-
})
|
|
15
|
-
}), a = n.succeed(e.Crypto, i);
|
|
16
|
-
//#endregion
|
|
17
|
-
export { i as webCrypto, a as webCryptoLayer };
|
|
1
|
+
import { Digest as e } from "effect/crypto";
|
|
2
|
+
// src/webCrypto.ts
|
|
3
|
+
var t = e.layerWebCrypto;
|
|
4
|
+
export { t as webCryptoLayer };
|
package/dist/workflowDelivery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context as e, Effect as t } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/workflowDelivery.ts
|
|
3
3
|
var n = "voltro-workflow-restart", r = class extends e.Service()("voltro/CurrentWorkflowDelivery") {}, i = (e) => ({
|
|
4
4
|
...e,
|
|
5
5
|
registerEntity: (n, i, a) => e.registerEntity(n, n.type.startsWith("Workflow/") ? i.pipe(t.map((e) => {
|
|
@@ -20,5 +20,4 @@ var n = "voltro-workflow-restart", r = class extends e.Service()("voltro/Current
|
|
|
20
20
|
};
|
|
21
21
|
})) : i, a)
|
|
22
22
|
});
|
|
23
|
-
//#endregion
|
|
24
23
|
export { r as CurrentWorkflowDelivery, n as WORKFLOW_RESTART_HEADER, i as withWorkflowDelivery };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { journalExecutorGroups as e } from "./journalRoutingLayout.js";
|
|
2
|
+
import { WorkflowEngine as t } from "effect/workflow";
|
|
3
|
+
import { Context as n, Effect as r, Layer as i, Option as a } from "effect";
|
|
4
|
+
// src/workflowExecutorRouting.ts
|
|
5
|
+
var o = n.Service("@voltro/workflow/WorkflowExecutorRouting"), s = (e, t, r, i, a) => n.add(e, o, Object.freeze({
|
|
6
|
+
engine: t,
|
|
7
|
+
mode: r,
|
|
8
|
+
state: i,
|
|
9
|
+
groups: a ?? Object.freeze({
|
|
10
|
+
available: Object.freeze(["default"]),
|
|
11
|
+
assigned: Object.freeze(r === "client" ? [] : ["default"])
|
|
12
|
+
})
|
|
13
|
+
})), c = (n, s) => {
|
|
14
|
+
let c = Object.freeze({
|
|
15
|
+
workflows: s.workflows,
|
|
16
|
+
schedules: s.schedules,
|
|
17
|
+
webhooks: s.webhooks
|
|
18
|
+
});
|
|
19
|
+
if (Object.values(c).some((e) => typeof e != "boolean")) throw Error("Explicit executor selection is required");
|
|
20
|
+
let l = Object.values(c).every(Boolean), u = Object.values(c).some(Boolean), d = r.gen(function* () {
|
|
21
|
+
let n = yield* r.serviceOption(t.WorkflowEngine);
|
|
22
|
+
if (a.isNone(n)) return yield* r.die(/* @__PURE__ */ Error("Executor registration requires a workflow engine"));
|
|
23
|
+
let i = yield* r.serviceOption(o);
|
|
24
|
+
if (a.isNone(i)) return l ? void 0 : yield* r.die(/* @__PURE__ */ Error("Selected executor roles require an engine routing contract"));
|
|
25
|
+
let s = i.value;
|
|
26
|
+
if (s.engine !== n.value || s.mode !== (u ? "worker" : "client")) return yield* r.die(/* @__PURE__ */ Error("Executor roles do not match the provided workflow engine"));
|
|
27
|
+
let d = yield* r.sync(() => e(s.state?.layout ?? "default", c)), f = (e, t) => e.length === t.length && e.every((e) => t.includes(e));
|
|
28
|
+
if (!f(s.groups.available, d.available) || !f(s.groups.assigned, d.assigned)) return yield* r.die(/* @__PURE__ */ Error("Executor roles do not match the engine shard ownership"));
|
|
29
|
+
});
|
|
30
|
+
return i.effectDiscard(d).pipe(i.provideMerge(n));
|
|
31
|
+
};
|
|
32
|
+
export { s as recordWorkflowExecutorRouting, c as withWorkflowExecutorSelection };
|
package/dist/workflowJournal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { latestExitReply as e } from "./workflowReadSelections.js";
|
|
2
2
|
import { Context as t, Effect as n, Option as r, Schema as i } from "effect";
|
|
3
3
|
import { ClusterSchema as a, EntityAddress as o, EntityId as s, EntityType as c, MessageStorage as l, Sharding as u } from "effect/cluster";
|
|
4
|
-
|
|
4
|
+
// src/workflowJournal.ts
|
|
5
5
|
var d = (e, t) => `${e}/${t}`, f = (e, n, r) => {
|
|
6
6
|
let i = s.make(n), l = t.get(e.annotations, a.ShardGroup)(i);
|
|
7
7
|
return new o.EntityAddress({
|
|
@@ -120,5 +120,4 @@ var d = (e, t) => `${e}/${t}`, f = (e, n, r) => {
|
|
|
120
120
|
reason: "run-reset-unconfirmed"
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
|
-
//#endregion
|
|
124
123
|
export { m as JournalExit, d as activityPrimaryKey, g as classifyRunReply, p as readWorkflowRunReply, _ as redriveFailedRun, v as resumeRunFromStep, f as runEntityAddress };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WORKFLOW_RESTART_HEADER as e } from "./workflowDelivery.js";
|
|
2
2
|
import { Effect as t, Schema as n } from "effect";
|
|
3
3
|
import { SqlClient as r } from "effect/sql";
|
|
4
|
-
|
|
4
|
+
// src/workflowJournalReset.ts
|
|
5
5
|
var i = n.fromJsonString(n.Struct({
|
|
6
6
|
_tag: n.Literal("Success"),
|
|
7
7
|
value: n.Struct({ _tag: n.Literal("Suspended") })
|
|
@@ -107,5 +107,4 @@ var i = n.fromJsonString(n.Struct({
|
|
|
107
107
|
};
|
|
108
108
|
}).pipe(d.withTransaction, t.provideService(r.SafeIntegers, !0));
|
|
109
109
|
}), c = (e, t) => s(e, t === void 0 ? {} : { restart: t }), l = (e) => s([e], { suspension: e });
|
|
110
|
-
//#endregion
|
|
111
110
|
export { o as observeWorkflowSuspension, c as resetExpectedWorkflowReplies, l as resetExpectedWorkflowSuspension };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/workflowReadSelections.ts
|
|
2
2
|
var e = (e) => e.findLast((e, t, n) => t in n && e._tag === "WithExit"), t = (e) => {
|
|
3
3
|
let t = /* @__PURE__ */ new Set();
|
|
4
4
|
for (let n of e) {
|
|
@@ -8,5 +8,4 @@ var e = (e) => e.findLast((e, t, n) => t in n && e._tag === "WithExit"), t = (e)
|
|
|
8
8
|
}
|
|
9
9
|
return t;
|
|
10
10
|
};
|
|
11
|
-
//#endregion
|
|
12
11
|
export { e as latestExitReply, t as terminalUpdates };
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { JournalRoutingGuard as e, protectJournalRoutingEffect as t, tryOwnedJournalRoutingPromise as n } from "./journalRoutingGuard.js";
|
|
2
|
+
import { resetReservedWorkflowJournal as r } from "./workflowRestartReservation.js";
|
|
3
|
+
import { JournalRoutingLayout as i, routeJournalWorkflow as a } from "./journalRoutingRuntime.js";
|
|
4
|
+
import { prepareWorkflowRestartCommand as o } from "./workflowRestartPreparation.js";
|
|
5
|
+
import { observeWorkflowRestartReplies as s } from "./workflowRestartObservation.js";
|
|
6
|
+
import { Context as c, Effect as l, Option as u } from "effect";
|
|
7
|
+
import { SqlClient as d } from "effect/sql";
|
|
8
|
+
import { MessageStorage as f, Sharding as p } from "effect/cluster";
|
|
9
|
+
// src/workflowRestartDispatch.ts
|
|
10
|
+
var m = (e) => l.gen(function* () {
|
|
11
|
+
let t = yield* r(e);
|
|
12
|
+
return t.kind === "waiting-capacity" ? t : (yield* (yield* p.Sharding).pollStorage, {
|
|
11
13
|
kind: "attempted",
|
|
12
|
-
journal:
|
|
14
|
+
journal: t
|
|
13
15
|
});
|
|
14
|
-
}),
|
|
15
|
-
let e = yield*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
}), h = class extends c.Service()("@voltro/workflow/WorkflowRestartDispatcher") {}, g = l.gen(function* () {
|
|
17
|
+
let r = u.getOrUndefined(yield* l.serviceOption(e)), c = u.getOrUndefined(yield* l.serviceOption(i)), g = yield* d.SqlClient, _ = yield* p.Sharding, v = yield* f.MessageStorage, y = (e) => t(r, s(c === void 0 ? e : {
|
|
18
|
+
...e,
|
|
19
|
+
workflow: a(e.workflow, c)
|
|
20
|
+
})).pipe(l.provideService(d.SqlClient, g), l.provideService(p.Sharding, _), l.provideService(f.MessageStorage, v));
|
|
21
|
+
return h.of({
|
|
22
|
+
prepare: (e) => t(r, n((t) => o({
|
|
23
|
+
...e,
|
|
24
|
+
transaction: (n) => {
|
|
25
|
+
if (t.throwIfAborted(), r?.isClosed()) throw Error("Journal routing admission is closed");
|
|
26
|
+
return e.transaction(n);
|
|
27
|
+
},
|
|
28
|
+
observe: (e) => l.runPromise(y(e), { signal: t })
|
|
29
|
+
}))),
|
|
30
|
+
observe: y,
|
|
31
|
+
dispatch: (e) => t(r, m(e)).pipe(l.provideService(d.SqlClient, g), l.provideService(p.Sharding, _))
|
|
26
32
|
});
|
|
27
33
|
});
|
|
28
|
-
|
|
29
|
-
export { l as WorkflowRestartDispatcher, c as dispatchWorkflowRestart, u as makeWorkflowRestartDispatcher };
|
|
34
|
+
export { h as WorkflowRestartDispatcher, m as dispatchWorkflowRestart, g as makeWorkflowRestartDispatcher };
|
|
@@ -3,7 +3,7 @@ import { activityPrimaryKey as e, classifyRunReply as t, runEntityAddress as n }
|
|
|
3
3
|
import { Effect as r, Option as i, Schema as a } from "effect";
|
|
4
4
|
import { SqlClient as o } from "effect/sql";
|
|
5
5
|
import { MessageStorage as s, Sharding as c } from "effect/cluster";
|
|
6
|
-
|
|
6
|
+
// src/workflowRestartObservation.ts
|
|
7
7
|
var l = a.fromJsonString(a.Record(a.String, a.String)), u = (u) => r.gen(function* () {
|
|
8
8
|
if (!/^[1-9]\d*$/.test(u.delivery.requestId) || u.executionId.length === 0 || u.activities.some((e) => e.name.length === 0 || !Number.isSafeInteger(e.attempt) || e.attempt < 1)) return yield* r.die(/* @__PURE__ */ Error("Restart observation requires an exact delivery and valid activity attempts"));
|
|
9
9
|
let d = (yield* o.SqlClient).withoutTransforms(), f = yield* s.MessageStorage, p = yield* c.Sharding, m = n(u.workflow, u.executionId, p), h = (e, t) => r.gen(function* () {
|
|
@@ -56,5 +56,4 @@ var l = a.fromJsonString(a.Record(a.String, a.String)), u = (u) => r.gen(functio
|
|
|
56
56
|
}))
|
|
57
57
|
};
|
|
58
58
|
}).pipe(r.provideService(o.SafeIntegers, !0));
|
|
59
|
-
//#endregion
|
|
60
59
|
export { u as observeWorkflowRestartReplies };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readWorkflowRestartCommandInTransaction as e, readWorkflowRestartReservationInTransaction as t, reserveWorkflowRestartInTransaction as n } from "./workflowRestartReservation.js";
|
|
2
2
|
import { Schema as r } from "effect";
|
|
3
3
|
import { eq as i } from "@voltro/database";
|
|
4
|
-
|
|
4
|
+
// src/workflowRestartPreparation.ts
|
|
5
5
|
var a = async (t) => {
|
|
6
6
|
if (t.workflow._tag !== t.command.workflowName || t.control.workflowName !== t.command.workflowName) throw Error("Restart preparation requires the matching workflow");
|
|
7
7
|
let n = await t.transaction(async (n) => {
|
|
@@ -105,5 +105,4 @@ var a = async (t) => {
|
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
};
|
|
108
|
-
//#endregion
|
|
109
108
|
export { s as prepareWorkflowRestart, a as prepareWorkflowRestartCommand };
|