@voltro/runtime 0.85.0 → 0.86.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 +666 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- package/dist/aggregate.js +42 -0
- package/dist/aggregateExtrema.js +80 -0
- package/dist/aggregateIvm.js +115 -0
- package/dist/analyticsMirror.js +228 -0
- package/dist/analyticsSink.js +38 -0
- package/dist/apiKeyUsage.js +33 -0
- package/dist/apiKeys.js +223 -0
- package/dist/apiKeysWiring.js +114 -0
- package/dist/approvalBuiltins.js +10 -0
- package/dist/approvals.js +269 -0
- package/dist/authMiddlewareLayer.js +47 -0
- package/dist/bindEvent.js +72 -0
- package/dist/bootListener.js +76 -0
- package/dist/bootRefusal.js +7 -0
- package/dist/bootStoreCodec.js +70 -0
- package/dist/businessRules.js +67 -0
- package/dist/changeClaimsTable.js +12 -0
- package/dist/circuitBreaker.js +72 -0
- package/dist/columnOnUpdate.js +23 -0
- package/dist/composeAnalytics.js +108 -0
- package/dist/computedQuery.js +4 -0
- package/dist/connectionBuiltins.js +81 -0
- package/dist/connectionCredentials.js +66 -0
- package/dist/connectionState.js +34 -0
- package/dist/connectionVault.js +410 -0
- package/dist/connectionsFacade.js +54 -0
- package/dist/coordinatedSchedule.js +139 -0
- package/dist/crdtHistory.js +138 -0
- package/dist/crdtMerge.js +179 -0
- package/dist/crdtVersionsTable.js +25 -0
- package/dist/credentialBound.js +12 -0
- package/dist/crud.js +72 -0
- package/dist/dataStore.js +679 -0
- package/dist/dataloader.js +61 -0
- package/dist/declaredTablesGuard.js +48 -0
- package/dist/defineExecutor.js +4 -0
- package/dist/dependencyGraph.js +32 -0
- package/dist/devices.js +228 -0
- package/dist/devicesWiring.js +168 -0
- package/dist/dialectReplicationAdapter.js +29 -0
- package/dist/dispatcher.js +447 -0
- package/dist/effectStore.js +71 -0
- package/dist/eventBus.js +260 -0
- package/dist/eventPublish.js +49 -0
- package/dist/events.js +193 -0
- package/dist/expectation.js +52 -0
- package/dist/expectationEvaluator.js +308 -0
- package/dist/experiment.js +96 -0
- package/dist/experimentEvaluator.js +245 -0
- package/dist/externalizedTasks.js +25 -0
- package/dist/fieldCipher.js +61 -0
- package/dist/fingerprint.js +21 -0
- package/dist/finops.js +42 -0
- package/dist/finopsAccountant.js +216 -0
- package/dist/handlerBody.js +8 -0
- package/dist/healthProbes.js +55 -0
- package/dist/httpClientSsrf.js +49 -0
- package/dist/httpClientTracing.js +11 -0
- package/dist/httpCompression.js +76 -0
- package/dist/httpKeepAlive.js +12 -0
- package/dist/httpRouteMounts.js +47 -0
- package/dist/idempotencyStore.js +70 -0
- package/dist/idleDetector.js +21 -0
- package/dist/index.d.ts +88 -69
- package/dist/index.js +144 -15292
- package/dist/insertRequiredColumns.js +19 -0
- package/dist/inspectWorkflow.js +1 -0
- package/dist/instanceMembership.js +98 -0
- package/dist/ivm.js +125 -0
- package/dist/kvDataStore.js +86 -0
- package/dist/kvFacade.js +32 -0
- package/dist/matcher.js +304 -0
- package/dist/memoryColumnDefaults.js +11 -0
- package/dist/memoryQueryJoins.js +114 -0
- package/dist/metrics.js +161 -0
- package/dist/observability.js +123 -0
- package/dist/observedGraph.js +52 -0
- package/dist/originGuard.js +116 -0
- package/dist/outbox.js +352 -0
- package/dist/pluginRefRules.js +65 -0
- package/dist/policyGuardResolver.js +55 -0
- package/dist/preview.js +62 -0
- package/dist/projectedRows.js +12 -0
- package/dist/provenance.js +63 -0
- package/dist/rangeIndex.js +89 -0
- package/dist/rawReadScope.js +17 -0
- package/dist/reaction.js +85 -0
- package/dist/reactiveConfig.js +11 -0
- package/dist/readClassification.js +57 -0
- package/dist/readRecorder.js +66 -0
- package/dist/rebac.js +104 -0
- package/dist/rebacInterceptor.js +81 -0
- package/dist/registry.js +29 -0
- package/dist/relevantFields.js +65 -0
- package/dist/replicaHealth.js +42 -0
- package/dist/replicaLocality.js +44 -0
- package/dist/replicaObservations.js +121 -0
- package/dist/replicaSelection.js +32 -0
- package/dist/replicatedDataStore.js +239 -0
- package/dist/requestLoader.js +7 -0
- package/dist/resumeCensus.js +28 -0
- package/dist/revalidation.js +22 -0
- package/dist/rowFilter.js +65 -0
- package/dist/rowStateBytes.js +45 -0
- package/dist/rpcBodyCap.js +63 -0
- package/dist/rpcConnections.js +83 -0
- package/dist/rpcDefectDiagnostics.js +15 -0
- package/dist/rpcServer.js +992 -0
- package/dist/runAsSystem.js +23 -0
- package/dist/rywPositionStore.js +84 -0
- package/dist/schedule.js +23 -0
- package/dist/scheduleBackfillRequests.js +151 -0
- package/dist/scheduleClaimsTable.js +11 -0
- package/dist/scheduleRunsTable.js +37 -0
- package/dist/scheduler.js +835 -0
- package/dist/schemaRegistry.js +65 -0
- package/dist/secretsResolver.js +35 -0
- package/dist/securityHeaders.js +33 -0
- package/dist/servePipeline.js +305 -0
- package/dist/serverOnlyAudit.js +66 -0
- package/dist/serverTracer.js +15 -0
- package/dist/serviceCredentials.js +40 -0
- package/dist/singleNodeOrchestrator.js +91 -0
- package/dist/sourceResolution.js +42 -0
- package/dist/storeMiddleware.js +880 -0
- package/dist/storeQuery.js +204 -0
- package/dist/storeRead.js +10 -0
- package/dist/subscriber.js +7 -0
- package/dist/subscriptionOutbox.js +139 -0
- package/dist/subscriptionRegistry.js +82 -0
- package/dist/subscriptionResume.js +132 -0
- package/dist/subscriptionSocketMetrics.js +65 -0
- package/dist/systemSubject.js +5 -0
- package/dist/tenantScope.js +23 -0
- package/dist/tenantSelection.js +27 -0
- package/dist/timeline.js +105 -0
- package/dist/traceContext.js +5 -0
- package/dist/traceSink.js +63 -0
- package/dist/traceSpansTable.js +29 -0
- package/dist/traceparent.js +34 -0
- package/dist/transactionSubject.js +12 -0
- package/dist/trustedProxy.js +155 -0
- package/dist/undo.js +129 -0
- package/dist/undoBuiltins.js +69 -0
- package/dist/undoCapture.js +74 -0
- package/dist/undoLogTable.js +16 -0
- package/dist/upsertBinding.js +20 -0
- package/dist/wakeOrchestrator.js +34 -0
- package/dist/wakeRegistry.js +71 -0
- package/dist/wakeRouter.js +63 -0
- package/dist/wakeSupervisor.js +62 -0
- package/dist/wakeupsTable.js +12 -0
- package/dist/webSocketGatewayRuntime.js +114 -0
- package/dist/webhookVerification.js +18 -0
- package/dist/wireColumnStrip.js +84 -0
- package/dist/workflowReadBuiltins.js +87 -0
- package/dist/workflowRuntime.js +708 -0
- package/package.json +7 -7
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NO_ROW_FILTER as e } from "./rowFilter.js";
|
|
2
|
+
import { wrapStoreWithMixinBehaviour as t } from "./storeMiddleware.js";
|
|
3
|
+
import { systemSubject as n } from "@voltro/protocol";
|
|
4
|
+
//#region src/runAsSystem.ts
|
|
5
|
+
var r, i = (e) => {
|
|
6
|
+
r = e;
|
|
7
|
+
}, a = () => {
|
|
8
|
+
r = void 0;
|
|
9
|
+
}, o = () => r, s = async (i, a = {}) => {
|
|
10
|
+
let o = a.scopes === void 0 ? n(a.id ?? "system") : n(a.id ?? "system", a.scopes), s = a.store ?? r?.dataStore, c = a.schemaRegistry ?? r?.schemaRegistry, l = a.dialect ?? r?.dialect;
|
|
11
|
+
if (s === void 0 || c === void 0) throw Error("runAsSystem: no data store available — register one at boot via setSystemStoreHandle({ dataStore, schemaRegistry }) or pass { store, schemaRegistry } in the options.");
|
|
12
|
+
return i({
|
|
13
|
+
subject: o,
|
|
14
|
+
store: t(s, {
|
|
15
|
+
subject: o,
|
|
16
|
+
schemaRegistry: c,
|
|
17
|
+
...l === void 0 ? {} : { dialect: l },
|
|
18
|
+
rowFilter: e
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { a as clearSystemStoreHandle, o as getSystemStoreHandle, s as runAsSystem, i as setSystemStoreHandle };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createLogger as e } from "@voltro/logger";
|
|
2
|
+
//#region src/rywPositionStore.ts
|
|
3
|
+
var t = e({ scope: "voltro:ryw" }), n = (e = {}) => {
|
|
4
|
+
let t = e.now ?? Date.now, n = /* @__PURE__ */ new Map();
|
|
5
|
+
return {
|
|
6
|
+
get(e) {
|
|
7
|
+
let r = n.get(e);
|
|
8
|
+
if (r !== void 0) {
|
|
9
|
+
if (r.expiresAt <= t()) n.delete(e);
|
|
10
|
+
else return r;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
set(e, t) {
|
|
14
|
+
n.set(e, t);
|
|
15
|
+
},
|
|
16
|
+
delete(e) {
|
|
17
|
+
n.delete(e);
|
|
18
|
+
},
|
|
19
|
+
size() {
|
|
20
|
+
return n.size;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, r = (e, t) => e === null ? t === void 0 ? "anon:bg" : `anon:${t}` : `subject:${e}`, i = (e) => {
|
|
24
|
+
let n = e.now ?? Date.now, r = e.keyPrefix ?? "voltro:ryw", i = e.channel ?? `${r}:bus`, a = e.onError ?? ((e, n) => {
|
|
25
|
+
t.warn("redis operation failed", {
|
|
26
|
+
op: n,
|
|
27
|
+
error: String(e)
|
|
28
|
+
});
|
|
29
|
+
}), o = `${process.pid ?? 0}:${Math.random() * 1e9 | 0}:${n()}`, s = /* @__PURE__ */ new Map(), c = (e) => {
|
|
30
|
+
if (e.senderId !== o) {
|
|
31
|
+
if (e.op === "set") {
|
|
32
|
+
if (e.position === void 0 || e.expiresAt === void 0) return;
|
|
33
|
+
s.set(e.subjectKey, {
|
|
34
|
+
position: e.position,
|
|
35
|
+
expiresAt: e.expiresAt
|
|
36
|
+
});
|
|
37
|
+
} else s.delete(e.subjectKey);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
e.subscriber.on("message", (e, t) => {
|
|
41
|
+
if (e === i) try {
|
|
42
|
+
let e = JSON.parse(t);
|
|
43
|
+
c(e);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
a(e, "parse");
|
|
46
|
+
}
|
|
47
|
+
}), e.subscriber.subscribe(i).catch((e) => a(e, "subscribe"));
|
|
48
|
+
let l = (t) => {
|
|
49
|
+
let n = JSON.stringify(t);
|
|
50
|
+
e.client.publish(i, n).catch((e) => a(e, t.op));
|
|
51
|
+
}, u = (e) => `${r}:${e}`;
|
|
52
|
+
return {
|
|
53
|
+
get(e) {
|
|
54
|
+
let t = s.get(e);
|
|
55
|
+
if (t !== void 0) {
|
|
56
|
+
if (t.expiresAt <= n()) s.delete(e);
|
|
57
|
+
else return t;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
set(t, r) {
|
|
61
|
+
s.set(t, r);
|
|
62
|
+
let i = r.expiresAt - n();
|
|
63
|
+
i > 0 && e.client.psetex(u(t), i, JSON.stringify(r)).catch((e) => a(e, "set")), l({
|
|
64
|
+
senderId: o,
|
|
65
|
+
op: "set",
|
|
66
|
+
subjectKey: t,
|
|
67
|
+
position: r.position,
|
|
68
|
+
expiresAt: r.expiresAt
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
delete(t) {
|
|
72
|
+
s.delete(t), e.client.del(u(t)).catch((e) => a(e, "delete")), l({
|
|
73
|
+
senderId: o,
|
|
74
|
+
op: "delete",
|
|
75
|
+
subjectKey: t
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
size() {
|
|
79
|
+
return s.size;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { r as buildSubjectKey, n as memoryRywPositionStore, i as redisRywPositionStore };
|
package/dist/schedule.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Cron as e, Result as t } from "effect";
|
|
2
|
+
//#region src/schedule.ts
|
|
3
|
+
var n = Symbol.for("@voltro/ScheduleDefinition"), r = (e) => typeof e == "object" && !!e && n in e, i = 18e5, a = (r) => {
|
|
4
|
+
let i = e.parse(r.cron, r.timezone);
|
|
5
|
+
if (t.isFailure(i)) throw Error(`defineSchedule("${r.name}"): invalid cron expression "${r.cron}" (tz="${r.timezone}") — ${String(i.failure)}`);
|
|
6
|
+
if (!r.timezone || r.timezone.trim() === "") throw Error(`defineSchedule("${r.name}"): timezone is required (e.g. "UTC", "Europe/Berlin").\nThe field is non-optional in \`ScheduleDefinition\`, so an ABSENT one is a tsc error and never reaches here. Arriving at this message means the value was present and EMPTY — almost always \`process.env.TZ ?? ''\` or a config lookup that missed. A reporter lost a crashloop to it, so the distinction is worth stating: this is not a check the type could have made for you.`);
|
|
7
|
+
if (r.trigger === "external" && r.cron.trim().split(/\s+/).length === 6) throw Error(`defineSchedule("${r.name}"): a six-field (seconds) cron "${r.cron}" cannot be driven by an external scheduler — k8s CronJob, EventBridge and Cloud Scheduler are all minute-resolution.
|
|
8
|
+
Use a five-field expression, or leave this schedule on trigger: 'self' (the in-app timer has no such limit).`);
|
|
9
|
+
if (r.handler === void 0 && r.workflow === void 0) throw Error(`defineSchedule("${r.name}"): define either handler or workflow`);
|
|
10
|
+
return {
|
|
11
|
+
...r,
|
|
12
|
+
onOverlap: r.onOverlap ?? "skip",
|
|
13
|
+
backfill: r.backfill ?? "skip",
|
|
14
|
+
maxRuntimeMs: r.maxRuntimeMs ?? 18e5,
|
|
15
|
+
[n]: !0
|
|
16
|
+
};
|
|
17
|
+
}, o = (t) => e.parseUnsafe(t.cron, t.timezone), s = (t, n = /* @__PURE__ */ new Date()) => e.next(o(t), n), c = (t, n, r, i) => {
|
|
18
|
+
let a = o(t), s = [], c = e.next(a, n);
|
|
19
|
+
for (; c.getTime() <= r.getTime() && s.length <= i;) s.push(c), c = e.next(a, c);
|
|
20
|
+
return s;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i as DEFAULT_MAX_RUNTIME_MS, o as compileCron, c as cronOccurrences, a as defineSchedule, r as isScheduleDefinition, s as nextFiring };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
import { and as t, eq as n, id as r, integer as i, isNull as a, json as o, lt as s, table as c, text as l, timestamp as u } from "@voltro/database";
|
|
3
|
+
import { ScheduleBackfillRequestConflict as d } from "@voltro/protocol/inspect";
|
|
4
|
+
//#region src/scheduleBackfillRequests.ts
|
|
5
|
+
var f = 5e3, p = 3e4, m = "_voltro_schedule_backfill_requests", h = c(m, {
|
|
6
|
+
id: r({ prefix: "schbackfill" }),
|
|
7
|
+
name: l(),
|
|
8
|
+
from: u(),
|
|
9
|
+
to: u(),
|
|
10
|
+
occurrences: o(),
|
|
11
|
+
status: l().oneOf([
|
|
12
|
+
"queued",
|
|
13
|
+
"running",
|
|
14
|
+
"completed",
|
|
15
|
+
"interrupted"
|
|
16
|
+
]),
|
|
17
|
+
owner: l().nullable(),
|
|
18
|
+
createdAt: u(),
|
|
19
|
+
updatedAt: u(),
|
|
20
|
+
cursor: i(),
|
|
21
|
+
activeIndex: i().nullable(),
|
|
22
|
+
results: o(),
|
|
23
|
+
error: l().nullable()
|
|
24
|
+
}), g = e.String.pipe(e.check(e.isMinLength(1)), e.check(e.isMaxLength(256))), _ = e.Struct({
|
|
25
|
+
runId: g,
|
|
26
|
+
status: e.Literals([
|
|
27
|
+
"succeeded",
|
|
28
|
+
"failed",
|
|
29
|
+
"skipped",
|
|
30
|
+
"missed"
|
|
31
|
+
])
|
|
32
|
+
}), v = e.Struct({
|
|
33
|
+
id: g,
|
|
34
|
+
name: g,
|
|
35
|
+
from: e.Date,
|
|
36
|
+
to: e.Date,
|
|
37
|
+
occurrences: e.Array(e.Number.pipe(e.check(e.isFinite()))),
|
|
38
|
+
status: e.Literals([
|
|
39
|
+
"queued",
|
|
40
|
+
"running",
|
|
41
|
+
"completed",
|
|
42
|
+
"interrupted"
|
|
43
|
+
]),
|
|
44
|
+
owner: e.NullOr(g),
|
|
45
|
+
createdAt: e.Date,
|
|
46
|
+
updatedAt: e.Date,
|
|
47
|
+
cursor: e.Number.pipe(e.check(e.isInt()), e.check(e.isGreaterThanOrEqualTo(0))),
|
|
48
|
+
activeIndex: e.NullOr(e.Number.pipe(e.check(e.isInt()), e.check(e.isGreaterThanOrEqualTo(0)))),
|
|
49
|
+
results: e.Array(_),
|
|
50
|
+
error: e.NullOr(e.String)
|
|
51
|
+
}), y = async (t, r) => {
|
|
52
|
+
let i = await t.query({
|
|
53
|
+
table: m,
|
|
54
|
+
predicate: n("id", r),
|
|
55
|
+
order: [],
|
|
56
|
+
take: 1,
|
|
57
|
+
skip: void 0,
|
|
58
|
+
projection: void 0
|
|
59
|
+
});
|
|
60
|
+
return i[0] === void 0 ? void 0 : e.decodeUnknownSync(v)(i[0]);
|
|
61
|
+
}, b = async (t, n) => {
|
|
62
|
+
let r = n.from.getTime(), i = n.to.getTime();
|
|
63
|
+
if (!Number.isFinite(r) || !Number.isFinite(i) || r >= i) throw Error("Invalid backfill range");
|
|
64
|
+
if (n.occurrences.length > 1e4) throw Error("Backfill occurrence limit exceeded");
|
|
65
|
+
let a = r, o = n.occurrences.map((e) => {
|
|
66
|
+
let t = e.getTime();
|
|
67
|
+
if (!Number.isFinite(t) || t <= a || t > i) throw Error("Backfill occurrences must be ordered within (from, to]");
|
|
68
|
+
return a = t, t;
|
|
69
|
+
}), s = e.decodeUnknownSync(v)({
|
|
70
|
+
...n,
|
|
71
|
+
occurrences: o,
|
|
72
|
+
status: "queued",
|
|
73
|
+
owner: null,
|
|
74
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
75
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
76
|
+
cursor: 0,
|
|
77
|
+
activeIndex: null,
|
|
78
|
+
results: [],
|
|
79
|
+
error: null
|
|
80
|
+
}), c = await t.insertIgnoreWithOutcome(m, s, { conflictColumns: ["id"] }), l = e.decodeUnknownSync(v)(c.row);
|
|
81
|
+
if (l.name !== s.name || l.from.getTime() !== r || l.to.getTime() !== i) throw new d("Backfill request ID already belongs to a different schedule or range");
|
|
82
|
+
return {
|
|
83
|
+
request: l,
|
|
84
|
+
created: c.outcome === "inserted"
|
|
85
|
+
};
|
|
86
|
+
}, x = async (r, i, a) => (e.decodeUnknownSync(g)(a), r.transactional(async (e) => await e.updateMany(m, {
|
|
87
|
+
status: "running",
|
|
88
|
+
owner: a,
|
|
89
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
90
|
+
}, { where: t(n("id", i), n("status", "queued")) }) === 1)), S = async (r, i, o, s) => {
|
|
91
|
+
if (!await x(r, i, o)) return y(r, i);
|
|
92
|
+
let c = await y(r, i);
|
|
93
|
+
if (!c) throw Error("Accepted backfill request disappeared");
|
|
94
|
+
let l = c, u = () => t(n("id", i), n("status", "running"), n("owner", o)), d, p, h = !1, g, v = () => {
|
|
95
|
+
d = setTimeout(() => {
|
|
96
|
+
p = r.transactional(async (e) => {
|
|
97
|
+
if (await e.updateMany("_voltro_schedule_backfill_requests", { updatedAt: /* @__PURE__ */ new Date() }, { where: u() }) !== 1) throw Error("Backfill ownership was lost");
|
|
98
|
+
}).then(() => {
|
|
99
|
+
h || v();
|
|
100
|
+
}, (e) => {
|
|
101
|
+
g = e;
|
|
102
|
+
});
|
|
103
|
+
}, f), d.unref?.();
|
|
104
|
+
};
|
|
105
|
+
v();
|
|
106
|
+
try {
|
|
107
|
+
for (let o = l.cursor; o < l.occurrences.length; o++) {
|
|
108
|
+
if (g !== void 0) throw g;
|
|
109
|
+
if (await r.transactional(async (e) => e.updateMany("_voltro_schedule_backfill_requests", {
|
|
110
|
+
activeIndex: o,
|
|
111
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
112
|
+
}, { where: t(u(), n("cursor", o), a("activeIndex")) })) !== 1) return y(r, i);
|
|
113
|
+
let c = e.decodeUnknownSync(_)(await s(new Date(l.occurrences[o]))), d = [...l.results, c];
|
|
114
|
+
if (await r.transactional(async (e) => e.updateMany("_voltro_schedule_backfill_requests", {
|
|
115
|
+
cursor: o + 1,
|
|
116
|
+
activeIndex: null,
|
|
117
|
+
results: d,
|
|
118
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
119
|
+
}, { where: t(u(), n("cursor", o), n("activeIndex", o)) })) !== 1) return y(r, i);
|
|
120
|
+
l = {
|
|
121
|
+
...l,
|
|
122
|
+
cursor: o + 1,
|
|
123
|
+
activeIndex: null,
|
|
124
|
+
results: d
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
await r.transactional(async (e) => e.updateMany(m, {
|
|
128
|
+
status: "completed",
|
|
129
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
130
|
+
}, { where: t(u(), n("cursor", l.occurrences.length), a("activeIndex")) }));
|
|
131
|
+
} catch (e) {
|
|
132
|
+
await r.transactional(async (t) => t.updateMany(m, {
|
|
133
|
+
status: "interrupted",
|
|
134
|
+
error: e instanceof Error ? e.message : String(e),
|
|
135
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
136
|
+
}, { where: u() }));
|
|
137
|
+
} finally {
|
|
138
|
+
h = !0, clearTimeout(d), await p;
|
|
139
|
+
}
|
|
140
|
+
return y(r, i);
|
|
141
|
+
}, C = (e, r = /* @__PURE__ */ new Date()) => e.transactional((e) => e.updateMany(m, {
|
|
142
|
+
status: "interrupted",
|
|
143
|
+
error: "Backfill owner stopped reporting; check the active run before starting another range",
|
|
144
|
+
updatedAt: r
|
|
145
|
+
}, { where: t(n("status", "running"), s("updatedAt", /* @__PURE__ */ new Date(r.getTime() - p))) })), w = (e, r) => e.transactional((e) => e.updateMany(m, {
|
|
146
|
+
status: "interrupted",
|
|
147
|
+
error: "Scheduler stopped before the backfill settled",
|
|
148
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
149
|
+
}, { where: t(n("status", "running"), n("owner", r)) }));
|
|
150
|
+
//#endregion
|
|
151
|
+
export { f as SCHEDULE_BACKFILL_HEARTBEAT_MS, m as SCHEDULE_BACKFILL_REQUESTS_TABLE, p as SCHEDULE_BACKFILL_STALE_MS, b as acceptScheduleBackfillRequest, x as claimScheduleBackfillRequest, S as executeScheduleBackfillRequest, w as interruptOwnedScheduleBackfills, C as interruptStaleScheduleBackfills, y as readScheduleBackfillRequest, h as scheduleBackfillRequestsTable };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { id as e, table as t, text as n, timestamp as r } from "@voltro/database";
|
|
2
|
+
//#region src/scheduleClaimsTable.ts
|
|
3
|
+
var i = t("_voltro_schedule_claims", {
|
|
4
|
+
id: e({ prefix: "schclaim" }),
|
|
5
|
+
scheduleName: n(),
|
|
6
|
+
bucket: n(),
|
|
7
|
+
claimedBy: n(),
|
|
8
|
+
claimedAt: r()
|
|
9
|
+
}).index(["scheduleName", "claimedAt"]).index(["claimedAt"]);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { i as _voltroScheduleClaimsTable };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { id as e, integer as t, json as n, table as r, text as i, timestamp as a } from "@voltro/database";
|
|
2
|
+
//#region src/scheduleRunsTable.ts
|
|
3
|
+
var o = r("_voltro_schedule_runs", {
|
|
4
|
+
id: e({ prefix: "schrun" }),
|
|
5
|
+
name: i(),
|
|
6
|
+
status: i().oneOf([
|
|
7
|
+
"running",
|
|
8
|
+
"queued",
|
|
9
|
+
"succeeded",
|
|
10
|
+
"failed",
|
|
11
|
+
"skipped",
|
|
12
|
+
"missed"
|
|
13
|
+
]).default("running"),
|
|
14
|
+
trigger: i().oneOf([
|
|
15
|
+
"self",
|
|
16
|
+
"external",
|
|
17
|
+
"manual"
|
|
18
|
+
]).default("self"),
|
|
19
|
+
scheduledAt: a(),
|
|
20
|
+
firedAt: a().nullable(),
|
|
21
|
+
completedAt: a().nullable(),
|
|
22
|
+
durationMs: t().nullable(),
|
|
23
|
+
errorTag: i().nullable(),
|
|
24
|
+
errorMessage: i().nullable(),
|
|
25
|
+
coordinationOutcome: i().oneOf([
|
|
26
|
+
"single",
|
|
27
|
+
"wonLock",
|
|
28
|
+
"lostLock",
|
|
29
|
+
"external",
|
|
30
|
+
"cluster"
|
|
31
|
+
]).nullable(),
|
|
32
|
+
replicaId: i().nullable(),
|
|
33
|
+
heartbeatAt: a().nullable(),
|
|
34
|
+
result: n().nullable()
|
|
35
|
+
}).index(["name", "scheduledAt"]).index(["status"]);
|
|
36
|
+
//#endregion
|
|
37
|
+
export { o as _voltroScheduleRunsTable };
|