add compliant worker ID to super simple queue

This commit is contained in:
Alex Holliday committed 2026-06-02 11:11:24 -07:00
1 parent caf8f22fec
commit b9fd29b906
1 file changed
+13 -2
@@ -3,6 +3,9 @@ import { ILogger } from "@/utils/logger.js";
import Scheduler from "super-simple-scheduler";
import { IQueueHelper } from "@/service/infrastructure/JobQueues/QueueHelper.js";
import { Monitor, MonitorType, supportsGeoCheck } from "@/types/monitor.js";
import { hostname } from "node:os";
import { randomUUID } from "node:crypto";
const SERVICE_NAME = "JobQueue";
type QueueJobFailure = {
@@ -61,6 +64,7 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
private logger: ILogger;
private helper: IQueueHelper;
private workerId: string;
private monitorsRepository: IMonitorsRepository;
private readonly scheduler: Scheduler;
@@ -70,6 +74,7 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
this.monitorsRepository = monitorsRepository;
this.scheduler = scheduler;
this.registerListeners();
this.workerId = `${hostname()}:${process.pid}:${randomUUID()}`;
}
get serviceName() {
@@ -354,7 +359,13 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
}>,
totalRuns: 0,
totalFailures: 0,
workers: [],
workers: [
{
workerId: this.workerId,
mode: "primary",
lastSeenAt: Date.now(),
},
],
}
);
return metrics;
@@ -372,7 +383,7 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
monitorActive: job.data?.isActive ?? null,
active: job.active,
repeat: job.repeat ?? null,
lockedBy: null,
lockedBy: job.lockedAt ? this.workerId : null,
lockedUntil: null,
lockedAt: job.lockedAt ?? null,
runCount: job.runCount ?? 0,