add observability to worker and health server

This commit is contained in:
Alex Holliday committed 2026-06-25 11:02:38 -07:00
1 parent 48ca64ec6f
commit f43bf9ab3d
3 files changed
+47 -1

No files matched your search

+13
View File
@@ -332,6 +332,10 @@ export class DBQueueWorker extends JobScheduler implements IQueueWorker {
await this.bufferService.shutdown(); // Flush buffers
};
// ************************
// Observability
// ************************
getHealth = () => {
return {
workerId: this.workerId,
@@ -343,4 +347,13 @@ export class DBQueueWorker extends JobScheduler implements IQueueWorker {
inFlight: this.getInFlightCount(),
};
};
countDueBacklog = () => {
return this.jobsRepository.countDueBacklog(Date.now());
};
countAliveWorkers = async () => {
const workers = await this.queueWorkersRepository.findRecent(WORKER_STALE_MS);
return workers.length;
};
}