add observability to worker and health server
This commit is contained in:
1 parent
48ca64ec6f
commit
f43bf9ab3d
3 files changed
+47
-1
No files matched your search
@@ -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;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user