App conventions
Bun apps
Rules for Bun apps without a framework, currently apps/api-ingest, apps/worker-errors and apps/worker-jobs.
What each process does is in the Self-hosting service pages.
Shared rules
- Logic lives in
packages/. A route or job handler only decodes its input and calls a function from there; nothing here redefines shared vocabulary or models. - Filenames are kebab-case:
otlp-route.ts,register-alert-workers.ts. Route handlers are exempt from verb-first names. Prefer Bun APIs. - Health comes from
@openperf/server/health:createHealthzfor readiness,serveHealthnext to/health/live, andhandleShutdownfor SIGTERM and SIGINT.
api-ingest
Routes live in src/routes/, assembled by server.ts. They answer OTLP conventions: empty protobuf or JSON bodies on success, and status codes mapped from domain errors.
worker-errors
Queue handlers live in src/jobs/. Its pg-boss instance neither supervises queues nor runs schedules.
worker-jobs
The only pg-boss instance that supervises queues and runs schedules. Handlers live in src/jobs/register-<domain>-workers.ts. A job belongs to the server module that owns its work: the module exports the queue names and options (alertQueues, alertQueueOptions), the payload type and, for a cron, a schedule<Module>Queues function that ensures the queues and registers the schedule.