pipework 0.198.0 → 0.199.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 +8 -0
- package/REFERENCE.md +3 -0
- package/dist/infra/alerts/beat.d.ts +6 -0
- package/dist/infra/alerts/beat.d.ts.map +1 -1
- package/dist/infra/alerts/beat.js +9 -0
- package/dist/infra/alerts/beat.js.map +1 -1
- package/dist/infra/alerts/faults.d.ts +4 -3
- package/dist/infra/alerts/faults.d.ts.map +1 -1
- package/dist/infra/alerts/faults.js +34 -10
- package/dist/infra/alerts/faults.js.map +1 -1
- package/dist/infra/alerts/namespace.d.ts +8 -1
- package/dist/infra/alerts/namespace.d.ts.map +1 -1
- package/dist/infra/alerts/namespace.js +8 -1
- package/dist/infra/alerts/namespace.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.199.0
|
|
4
|
+
|
|
5
|
+
- **Added: a process that is not a pipework surface can record faults and loop beats** (#769). Before this, `alerts.recordFault` outside a Flow did nothing unless a worker surface had registered a target. Now:
|
|
6
|
+
- **`alerts.useFaultTarget(manifold | db | () => db)`:** a custom drain registers once at boot. It returns the release to call at shutdown. A manifold without `alerts` registers nothing.
|
|
7
|
+
- **`alerts.recordFaultFor(manifold, kind, message, context?)`:** writes a fault from code that holds the manifold.
|
|
8
|
+
- **`alerts.recordBeat(manifold, name, { ok, error?, everyMs })`:** your own loop beats for `alerts.source.loopStalled`, recorded outside any Flow.
|
|
9
|
+
- **Changed: a fault with nowhere to go is no longer silent.** When there is no Flow and no registered target, `recordFault` logs one warning per kind: `fault "<kind>" dropped: no Flow and no fault target; call alerts.useFaultTarget(manifold) at boot`.
|
|
10
|
+
|
|
3
11
|
## 0.198.0
|
|
4
12
|
|
|
5
13
|
- **Added: a queue job's claim history** (#765). Queue tables gain `claims jsonb NOT NULL DEFAULT '[]'`.
|
package/REFERENCE.md
CHANGED
|
@@ -1792,6 +1792,9 @@ Pass in `sources`; each raises with a fixed key on a tick and, where it can tell
|
|
|
1792
1792
|
- `alerts.source.traces({ graceMs? = 93_600_000, settleMs?, severity?, owner?, runbook?, database? })` — `trace-expired:<entryKind>` for traces the expiry sweep force-closed since the last tick (read from `closed_at` where `status = 'expired'`); `trace-expiry-undrained:all` while open traces are more than `graceMs` (default 26 h, as the maintenance job is daily) past `expires_at`, meaning the expiry job is not running. Needs the `trace` block in the blueprint.
|
|
1793
1793
|
- `alerts.source.faults({ kinds?, settleMs?, severity? = 'error', owner?, runbook?, database? })` — failures that code swallowed and only logged, recorded in `pipework_faults` (comes with the `alerts` blueprint flag; not tenant-scoped): `fault:<kind>`, message `<count> <kind> fault(s); last: <message>`, context `count`, `lastMessage`, `lastContext`; clears by the quiet period. `kinds` limits it. Pipework records `audit-write` (alert, auth, email, storage, support audit writes and read touches), `quota-record`, `credits-callback`, `trace-steps-lost`, `trace-write`, `trace-record`, `support-inbound-untenanted`, `queue-listener`, `queue-reaper`, `queue-heartbeat`, `scheduler`, `job-event-callback`, `queue-handback`, `step-graph-on-failed`, `inbound-raw-delete`, `access-link-on-miss` and `client-fault-raise`.
|
|
1794
1794
|
- `alerts.recordFault(kind, message, context?)` — records a failure your own code swallowed so the faults source can raise it: `void alerts.recordFault('webhook-parse', err.message, { id })` next to the log line. Best effort: never throws (a failed write is one `log.warn`), does nothing where the blueprint has no `alerts`, writes on the system connection outside the caller's transaction (so a rollback keeps it), stores the current tenant, cuts `message` at 2000 characters, and redacts email addresses from message and context before storing. Rows older than `occurrenceRetentionMs` are pruned by the tick, as occurrences are. `kind` is a short stable name.
|
|
1795
|
+
- `alerts.useFaultTarget(manifold | db | () => db)` — registers where `alerts.recordFault` writes when it runs outside any Flow, for a process that is not a pipework surface (a custom queue drain). Call it once at boot and keep the release for shutdown: `const release = alerts.useFaultTarget(manifold)` ... `release()`. A manifold resolves lazily to its default database and registers nothing (the release is a no-op) where the blueprint has no `alerts`. With no Flow and no target, `recordFault` writes nothing and logs one warn per kind per process: `fault "<kind>" dropped: no Flow and no fault target; call alerts.useFaultTarget(manifold) at boot`.
|
|
1796
|
+
- `alerts.recordFaultFor(manifold, kind, message, context?)` — `recordFault` for code that holds the manifold: writes on its default database with no Flow and no registered target; never warns, does nothing without `alerts`.
|
|
1797
|
+
- `alerts.recordBeat(manifold, name, { ok, error?, everyMs })` — one iteration of a background loop of your own, for `alerts.source.loopStalled` to raise when it stops. Works outside any Flow on the manifold's default database; best effort, never throws, does nothing without `alerts`.
|
|
1795
1798
|
- `queue.totals(db)` — `{ overall, byType }`, each `{ ready, running, oldestReadyWaitMs }` (ready: pending and not waiting on a retry time; running: claimed or running; wait from `queued_at`, null when none is ready); `byType` omits a type with neither.
|
|
1796
1799
|
- `alerts.source.health(checks, { severity? = 'error' })` — `health:<name>` while a `HealthCheck` is unhealthy or throws; resolves when it recovers. Degraded is not a fault.
|
|
1797
1800
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DB } from '../../data/db/index.js';
|
|
2
|
+
import type { Manifold } from '../../core/pipework.js';
|
|
2
3
|
/** The loops pipework itself records. */
|
|
3
4
|
export declare const LOOP_NAMES: readonly ["alerts.tick", "jobs.scheduler", "jobs.reaper", "jobs.claim", "support.events"];
|
|
4
5
|
export declare const ALERTS_TICK_LOOP = "alerts.tick";
|
|
@@ -10,6 +11,11 @@ export interface BeatOutcome {
|
|
|
10
11
|
}
|
|
11
12
|
/** Records one iteration of a loop. Never throws: a failed beat is logged and the loop carries on. */
|
|
12
13
|
export declare function recordBeat(db: DB | (() => DB), name: string, outcome: BeatOutcome): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* `recordBeat` for a loop in a process that is not a pipework surface: writes on the manifold's default database,
|
|
16
|
+
* outside any Flow, and does nothing where the blueprint has no `alerts`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function recordBeatFor(instance: Manifold, name: string, outcome: BeatOutcome): Promise<void>;
|
|
13
19
|
/** Whether a blueprint has the `alerts` flag, which brings the beat table. */
|
|
14
20
|
export declare function beatsEnabled(config: {
|
|
15
21
|
readonly raw: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beat.d.ts","sourceRoot":"","sources":["../../../src/infra/alerts/beat.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"beat.d.ts","sourceRoot":"","sources":["../../../src/infra/alerts/beat.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAA;AAEhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEtD,yCAAyC;AACzC,eAAO,MAAM,UAAU,2FAA4F,CAAA;AACnH,eAAO,MAAM,gBAAgB,gBAAgB,CAAA;AAC7C,eAAO,MAAM,qBAAqB,QAAS,CAAA;AAI3C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,sGAAsG;AACtG,wBAAsB,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnG;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAGv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|
|
33
|
+
/**
|
|
34
|
+
* `recordBeat` for a loop in a process that is not a pipework surface: writes on the manifold's default database,
|
|
35
|
+
* outside any Flow, and does nothing where the blueprint has no `alerts`.
|
|
36
|
+
*/
|
|
37
|
+
export function recordBeatFor(instance, name, outcome) {
|
|
38
|
+
if (!beatsEnabled(instance.config))
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
return recordBeat(() => instance.pool.getOrCreate(instance.config.database()).drizzle, name, outcome);
|
|
41
|
+
}
|
|
33
42
|
/** Whether a blueprint has the `alerts` flag, which brings the beat table. */
|
|
34
43
|
export function beatsEnabled(config) {
|
|
35
44
|
const raw = config.raw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beat.js","sourceRoot":"","sources":["../../../src/infra/alerts/beat.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,gEAAgE;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"beat.js","sourceRoot":"","sources":["../../../src/infra/alerts/beat.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,gEAAgE;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAG3D,yCAAyC;AACzC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,CAAU,CAAA;AACnH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAC3C,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAQ5B,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAmB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CAAA;QACrD,MAAM,OAAO,GAAG,MAAM;YACpB,CAAC,CAAC,GAAG,IAAI,mBAAmB,SAAS,CAAC,KAAK,CAAC,EAAE;YAC9C,CAAC,CAAC,GAAG,IAAI,yBAAyB,SAAS,CAAC,KAAK,CAAC,iBAAiB,SAAS,IAAI,MAAM,EAAE,CAAA;QAC1F,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAA;IACxH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAC5C,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAC3B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAoB,CAAC,CAAC,CAAA;AACvF,CAAC"}
|
|
@@ -3,10 +3,11 @@ import type { Manifold } from '../../core/pipework.js';
|
|
|
3
3
|
import type { AlertSeverity, JsonValue } from './handle.js';
|
|
4
4
|
import { type AlertSource } from './sources.js';
|
|
5
5
|
/**
|
|
6
|
-
* Registers the connection faults raised outside any Flow are written on (a worker's loops
|
|
7
|
-
*
|
|
6
|
+
* Registers the connection faults raised outside any Flow are written on (a worker's loops, or a custom drain
|
|
7
|
+
* process); returns the release. Pass the manifold to use its default database, resolved when a fault is written; it
|
|
8
|
+
* registers nothing where the blueprint has no `alerts`. A `DB` or a function returning one is used as given.
|
|
8
9
|
*/
|
|
9
|
-
export declare function useFaultTarget(
|
|
10
|
+
export declare function useFaultTarget(target: Manifold | DB | (() => DB)): () => void;
|
|
10
11
|
/**
|
|
11
12
|
* Records a failure the code swallowed, for `alerts.source.faults` to raise. Call it as `void recordFault(...)` next
|
|
12
13
|
* to the log line. Best effort: it never throws, does nothing where the blueprint has no `alerts`, writes outside the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faults.d.ts","sourceRoot":"","sources":["../../../src/infra/alerts/faults.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAA;AAGhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"faults.d.ts","sourceRoot":"","sources":["../../../src/infra/alerts/faults.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAA;AAGhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAc9D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,IAAI,CAc7E;AAsBD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvH;AAED,mGAAmG;AACnG,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAS9I;AA2BD,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEjD;AAED,UAAU,MAAM;IAAG,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;AAElG;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,WAAW,CA4BjH"}
|
|
@@ -9,15 +9,26 @@ import { beatsEnabled } from './beat.js';
|
|
|
9
9
|
import { newRowsSource } from './sources.js';
|
|
10
10
|
const MAX_MESSAGE_LENGTH = 2000;
|
|
11
11
|
const targets = [];
|
|
12
|
+
const isManifold = (v) => typeof v === 'object' && v !== null && 'pool' in v && 'config' in v;
|
|
12
13
|
/**
|
|
13
|
-
* Registers the connection faults raised outside any Flow are written on (a worker's loops
|
|
14
|
-
*
|
|
14
|
+
* Registers the connection faults raised outside any Flow are written on (a worker's loops, or a custom drain
|
|
15
|
+
* process); returns the release. Pass the manifold to use its default database, resolved when a fault is written; it
|
|
16
|
+
* registers nothing where the blueprint has no `alerts`. A `DB` or a function returning one is used as given.
|
|
15
17
|
*/
|
|
16
|
-
export function useFaultTarget(
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
export function useFaultTarget(target) {
|
|
19
|
+
let db;
|
|
20
|
+
if (isManifold(target)) {
|
|
21
|
+
if (!beatsEnabled(target.config))
|
|
22
|
+
return () => undefined;
|
|
23
|
+
db = () => target.pool.getOrCreate(target.config.database()).drizzle;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
db = target;
|
|
27
|
+
}
|
|
28
|
+
const entry = { db };
|
|
29
|
+
targets.push(entry);
|
|
19
30
|
return () => {
|
|
20
|
-
const i = targets.indexOf(
|
|
31
|
+
const i = targets.indexOf(entry);
|
|
21
32
|
if (i >= 0)
|
|
22
33
|
targets.splice(i, 1);
|
|
23
34
|
};
|
|
@@ -32,13 +43,23 @@ function resolveTarget() {
|
|
|
32
43
|
const t = targets[targets.length - 1];
|
|
33
44
|
return t === undefined ? null : { db: t.db, tenant: null };
|
|
34
45
|
}
|
|
46
|
+
const warnedDropped = new Set();
|
|
47
|
+
function warnDropped(kind) {
|
|
48
|
+
if (warnedDropped.has(kind))
|
|
49
|
+
return;
|
|
50
|
+
warnedDropped.add(kind);
|
|
51
|
+
try {
|
|
52
|
+
getBaseLogger().warn({ kind }, `fault "${kind}" dropped: no Flow and no fault target; call alerts.useFaultTarget(manifold) at boot`);
|
|
53
|
+
}
|
|
54
|
+
catch { /* logging must not break the caller */ }
|
|
55
|
+
}
|
|
35
56
|
/**
|
|
36
57
|
* Records a failure the code swallowed, for `alerts.source.faults` to raise. Call it as `void recordFault(...)` next
|
|
37
58
|
* to the log line. Best effort: it never throws, does nothing where the blueprint has no `alerts`, writes outside the
|
|
38
59
|
* caller's transaction, and records the current tenant. `kind` is a short stable name; `message` is cut at 2000 characters. Email addresses are redacted from both before they are stored.
|
|
39
60
|
*/
|
|
40
61
|
export function recordFault(kind, message, context) {
|
|
41
|
-
return write(resolveTarget, kind, message, context);
|
|
62
|
+
return write(resolveTarget, kind, message, context, true);
|
|
42
63
|
}
|
|
43
64
|
/** `recordFault` for code that holds the manifold but may run outside any Flow (a trace flush). */
|
|
44
65
|
export function recordFaultFor(instance, kind, message, context) {
|
|
@@ -50,13 +71,16 @@ export function recordFaultFor(instance, kind, message, context) {
|
|
|
50
71
|
db: () => instance.pool.getOrCreate(instance.config.database()).drizzle,
|
|
51
72
|
tenant: flow?.tenant ?? null,
|
|
52
73
|
};
|
|
53
|
-
}, kind, message, context);
|
|
74
|
+
}, kind, message, context, false);
|
|
54
75
|
}
|
|
55
|
-
async function write(resolve, kind, message, context) {
|
|
76
|
+
async function write(resolve, kind, message, context, warnWhenUnresolved) {
|
|
56
77
|
try {
|
|
57
78
|
const target = resolve();
|
|
58
|
-
if (target === null)
|
|
79
|
+
if (target === null) {
|
|
80
|
+
if (warnWhenUnresolved && getContext() === undefined)
|
|
81
|
+
warnDropped(kind);
|
|
59
82
|
return;
|
|
83
|
+
}
|
|
60
84
|
const conn = typeof target.db === 'function' ? target.db() : target.db;
|
|
61
85
|
await conn.execute(sql `
|
|
62
86
|
INSERT INTO pipework_faults (kind, message, context, tenant_id, recorded_at)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faults.js","sourceRoot":"","sources":["../../../src/infra/alerts/faults.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,oHAAoH;AAEpH,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,aAAa,EAAoB,MAAM,cAAc,CAAA;AAE9D,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAO/B,MAAM,OAAO,GAAkB,EAAE,CAAA;AAEjC
|
|
1
|
+
{"version":3,"file":"faults.js","sourceRoot":"","sources":["../../../src/infra/alerts/faults.ts"],"names":[],"mappings":"AAA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AAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,oBAAoB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;QACrF,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACnD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YACb,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACpC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAc;SACtD,CAAC;KACH,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -4,7 +4,8 @@ import { clientFaults } from './client-faults.js';
|
|
|
4
4
|
import { webhookSink, memorySink } from './sinks.js';
|
|
5
5
|
import { requestFaultsHook } from './request-faults.js';
|
|
6
6
|
import { deadLetterSource, longRunningSource, backlogSource, healthSource, quotaExhaustedSource, unitFaultSource, loopStalledSource, loopCheck, querySource, newRowsSource } from './sources.js';
|
|
7
|
-
import { recordFault, faultsSource } from './faults.js';
|
|
7
|
+
import { recordFault, recordFaultFor, useFaultTarget, faultsSource } from './faults.js';
|
|
8
|
+
import { recordBeatFor } from './beat.js';
|
|
8
9
|
import { deliveryFailedSource, webhookFailedSource, creditsSource } from './subsystem-sources.js';
|
|
9
10
|
import { emailSource, storageSource, accessLinksSource, lockoutsSource } from './infra-sources.js';
|
|
10
11
|
import { schedulesSource, stepsSource, pipelinesSource, tracesSource } from './async-sources.js';
|
|
@@ -26,6 +27,12 @@ export declare const alerts: {
|
|
|
26
27
|
readonly loopCheck: typeof loopCheck;
|
|
27
28
|
/** Records a failure your code swallowed (logged and carried on) so `alerts.source.faults` can raise it; `void alerts.recordFault('my-kind', message, context?)`. Best effort, never throws, writes outside the caller's transaction. Does nothing without `alerts` in the blueprint. */
|
|
28
29
|
readonly recordFault: typeof recordFault;
|
|
30
|
+
/** `recordFault` for code that holds the manifold and may run outside any Flow: `void alerts.recordFaultFor(manifold, kind, message, context?)`. */
|
|
31
|
+
readonly recordFaultFor: typeof recordFaultFor;
|
|
32
|
+
/** Registers the manifold (or a `DB`, or a function returning one) that `alerts.recordFault` writes on outside any Flow; call once at boot in a process that is not a pipework surface, and keep the release for shutdown. A manifold without `alerts` registers nothing. */
|
|
33
|
+
readonly useFaultTarget: typeof useFaultTarget;
|
|
34
|
+
/** Records one iteration of a background loop of your own for `alerts.source.loopStalled`: `void alerts.recordBeat(manifold, 'my-loop', { ok, error?, everyMs })`. Works outside any Flow; does nothing without `alerts`. */
|
|
35
|
+
readonly recordBeat: typeof recordBeatFor;
|
|
29
36
|
readonly source: {
|
|
30
37
|
/** Raises `job-dead-letter:<jobType>` for jobs that ran out of attempts. */
|
|
31
38
|
readonly deadLetter: typeof deadLetterSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/infra/alerts/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,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5E,iFAAiF;;QAEjF,mGAAmG;;QAEnG,yGAAyG;;QAEzG,yDAAyD;;QAEzD,6IAA6I;;QAE7I,2HAA2H;;QAE3H,iIAAiI;;QAEjI,0IAA0I;;QAE1I,yJAAyJ;;QAEzJ,gIAAgI;;QAEhI,4JAA4J;;QAE5J,+EAA+E;;QAE/E,gGAAgG;;QAEhG,oHAAoH;;QAEpH,kIAAkI;;QAElI,iKAAiK;;QAEjK,qLAAqL;;QAErL,qKAAqK;;QAErK,yPAAyP;;QAEzP,gNAAgN;;;CAG1M,CAAA"}
|
|
@@ -4,7 +4,8 @@ import { clientFaults } from './client-faults.js';
|
|
|
4
4
|
import { webhookSink, memorySink } from './sinks.js';
|
|
5
5
|
import { requestFaultsHook } from './request-faults.js';
|
|
6
6
|
import { deadLetterSource, longRunningSource, backlogSource, healthSource, quotaExhaustedSource, unitFaultSource, loopStalledSource, loopCheck, querySource, newRowsSource } from './sources.js';
|
|
7
|
-
import { recordFault, faultsSource } from './faults.js';
|
|
7
|
+
import { recordFault, recordFaultFor, useFaultTarget, faultsSource } from './faults.js';
|
|
8
|
+
import { recordBeatFor } from './beat.js';
|
|
8
9
|
import { deliveryFailedSource, webhookFailedSource, creditsSource } from './subsystem-sources.js';
|
|
9
10
|
import { emailSource, storageSource, accessLinksSource, lockoutsSource } from './infra-sources.js';
|
|
10
11
|
import { schedulesSource, stepsSource, pipelinesSource, tracesSource } from './async-sources.js';
|
|
@@ -26,6 +27,12 @@ export const alerts = {
|
|
|
26
27
|
loopCheck,
|
|
27
28
|
/** Records a failure your code swallowed (logged and carried on) so `alerts.source.faults` can raise it; `void alerts.recordFault('my-kind', message, context?)`. Best effort, never throws, writes outside the caller's transaction. Does nothing without `alerts` in the blueprint. */
|
|
28
29
|
recordFault,
|
|
30
|
+
/** `recordFault` for code that holds the manifold and may run outside any Flow: `void alerts.recordFaultFor(manifold, kind, message, context?)`. */
|
|
31
|
+
recordFaultFor,
|
|
32
|
+
/** Registers the manifold (or a `DB`, or a function returning one) that `alerts.recordFault` writes on outside any Flow; call once at boot in a process that is not a pipework surface, and keep the release for shutdown. A manifold without `alerts` registers nothing. */
|
|
33
|
+
useFaultTarget,
|
|
34
|
+
/** Records one iteration of a background loop of your own for `alerts.source.loopStalled`: `void alerts.recordBeat(manifold, 'my-loop', { ok, error?, everyMs })`. Works outside any Flow; does nothing without `alerts`. */
|
|
35
|
+
recordBeat: recordBeatFor,
|
|
29
36
|
source: {
|
|
30
37
|
/** Raises `job-dead-letter:<jobType>` for jobs that ran out of attempts. */
|
|
31
38
|
deadLetter: deadLetterSource,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/infra/alerts/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAChM,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/infra/alerts/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE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