Both caught a failed write and took the event, losing it silently; the SDK's rule is to throw when the work was not done. A failed write now throws so the bus offers the event again, and is spooled on disk at once; on its last delivery the spooled event is taken, and a background pass replays the spool once writing works. The runtime does not pass the delivery count, so the spool counts failed deliveries itself, across restarts. Over its bound (1000 events or 30 minutes) the last delivery is no longer taken, so the bus gives it up and the controller raises max-deliveries - the one existing condition that names a consumer which cannot keep up - while the spool still holds it. Writes are idempotent by event: the trail skips an id it already wrote; the usage upsert keeps the reading observed latest (migration 2), so a late replay never overwrites a newer one. Each module has a status tool for the spool, declared as valuable data (ADR 0233). model-usage moves to the bundle shape (ADR 0198) with its schema in a prepare step and numbered migrations; its old container shape had no image. Both on mesh-sdk 0.1.13. The log-only handlers of redis, mssql, mosquitto, mongodb, mesh-vault, showcase and the catalogue no longer throw a TypeError on an event without a body.
22 lines
1.1 KiB
TypeScript
22 lines
1.1 KiB
TypeScript
// Ambient types for `pg` (node-postgres), which ships its types only via the separate `@types/pg`
|
|
// package. Rather than pull that in at tsc time, this declares the exact slice model-usage uses —
|
|
// the same precedent anthropic-manager sets for `tweetnacl-sealedbox-js` (a local ambient .d.ts,
|
|
// listed in tsconfig `include`, default-imported). The real `pg` is installed into the module's
|
|
// runtime image (package.json `dependencies`; novox/hq ADR 0052), so this types the code without
|
|
// deciding what runs.
|
|
declare module "pg" {
|
|
/** A lazily-connecting connection pool. Only the connection string and two timeouts, one query form,
|
|
* and end() are used here. */
|
|
export class Pool {
|
|
constructor(config?: {
|
|
connectionString?: string;
|
|
/** How long a connection may take before the query fails (ms). */
|
|
connectionTimeoutMillis?: number;
|
|
/** How long a query may take before it fails, client side (ms). */
|
|
query_timeout?: number;
|
|
});
|
|
query(text: string, params?: unknown[]): Promise<{ rows: any[]; rowCount: number }>;
|
|
end(): Promise<void>;
|
|
}
|
|
}
|