perf(api): bound worker pools and add telemetry

Share one configured PostgreSQL pool across worker repositories and make API and worker connection budgets explicit.

Add privacy-safe aggregate request, query, pool, sync, and outbox telemetry, a loopback-only representative load fixture, bounded worker shutdown, and focused regression and integration coverage.

Document the database-wide budget formula and defer pg_stat_statements activation to a reviewed migration and planned restart.
This commit is contained in:
jjbrunton committed 2026-08-29 22:43:27 +01:00
1 parent a13bbc3f65
commit 5c973c4ac5
25 files changed
+471 -16

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, it } from 'vitest';
import { requireLocalApi, requireLoopback } from '../src/load/loopback.js';
describe('representative load fixture boundary', () => {
it('accepts only loopback API and PostgreSQL URLs', () => {
expect(requireLoopback('http://127.0.0.1:3003', 'API').hostname).toBe('127.0.0.1');
expect(requireLoopback('postgresql://sauci:test@localhost:5432/sauci', 'DATABASE').hostname).toBe('localhost');
expect(() => requireLoopback('https://api.sauci.example', 'API')).toThrow('must resolve to loopback');
expect(() => requireLoopback('postgresql://sauci:test@db.internal:5432/sauci', 'DATABASE')).toThrow('must resolve to loopback');
});
it('allows only the controlled local HTTP API port', () => {
expect(requireLocalApi('http://127.0.0.1:3003').port).toBe('3003');
expect(() => requireLocalApi('https://127.0.0.1:3003')).toThrow('must be http loopback');
expect(() => requireLocalApi('http://127.0.0.1:3004')).toThrow('must be http loopback');
});
});