2026-05-29 10:27:38 -07:00
|
|
|
import { Monitor } from "@/types/monitor.js";
|
2026-06-02 09:47:00 -07:00
|
|
|
import { QueueWorker } from "@/types/settings.js";
|
2026-05-29 10:27:38 -07:00
|
|
|
|
|
|
|
|
export type QueueJobFailure = {
|
|
|
|
|
monitorId: string | number;
|
|
|
|
|
monitorUrl: string | null;
|
|
|
|
|
monitorType: string | null;
|
|
|
|
|
failedAt: number | null;
|
|
|
|
|
failCount: number;
|
|
|
|
|
failReason: string | null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type QueueMetrics = {
|
|
|
|
|
jobs: number;
|
|
|
|
|
activeJobs: number;
|
|
|
|
|
failingJobs: number;
|
|
|
|
|
jobsWithFailures: QueueJobFailure[];
|
|
|
|
|
totalRuns: number;
|
|
|
|
|
totalFailures: number;
|
2026-06-02 09:47:00 -07:00
|
|
|
workers: QueueWorker[];
|
2026-05-29 10:27:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type QueueJobSummary = {
|
|
|
|
|
monitorId: string | number;
|
|
|
|
|
monitorUrl: string | null;
|
|
|
|
|
monitorType: string | null;
|
|
|
|
|
monitorInterval: number | null;
|
|
|
|
|
monitorGeoInterval: number | null;
|
|
|
|
|
monitorActive: boolean | null;
|
|
|
|
|
active: boolean;
|
2026-06-02 09:47:00 -07:00
|
|
|
lockedBy: string | null;
|
|
|
|
|
lockedUntil: number | null;
|
2026-05-29 10:27:38 -07:00
|
|
|
lockedAt: number | null;
|
|
|
|
|
runCount: number;
|
|
|
|
|
failCount: number;
|
|
|
|
|
failReason: string | null;
|
2026-05-29 11:20:19 -07:00
|
|
|
lastRunAt: number | null;
|
2026-05-29 10:27:38 -07:00
|
|
|
lastFinishedAt: number | null;
|
|
|
|
|
lastRunTook: number | null;
|
|
|
|
|
lastFailedAt: number | null;
|
|
|
|
|
repeat: number | null;
|
|
|
|
|
};
|
|
|
|
|
|
2026-06-03 13:28:53 -07:00
|
|
|
export type QueueJobsPagination = {
|
|
|
|
|
page?: number;
|
|
|
|
|
rowsPerPage?: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type QueueJobsPage = {
|
|
|
|
|
jobs: QueueJobSummary[];
|
|
|
|
|
count: number;
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-29 10:27:38 -07:00
|
|
|
export interface IJobQueue {
|
|
|
|
|
readonly serviceName: string;
|
|
|
|
|
init(): Promise<boolean>;
|
|
|
|
|
addJob(monitorId: string, monitor: Monitor): Promise<void>;
|
|
|
|
|
deleteJob(monitor: Monitor): Promise<void>;
|
|
|
|
|
pauseJob(monitor: Monitor): Promise<void>;
|
|
|
|
|
resumeJob(monitor: Monitor): Promise<void>;
|
|
|
|
|
updateJob(monitor: Monitor): Promise<void>;
|
|
|
|
|
shutdown(): Promise<void>;
|
|
|
|
|
getMetrics(): Promise<QueueMetrics>;
|
2026-06-03 13:28:53 -07:00
|
|
|
getJobs(pagination: QueueJobsPagination): Promise<QueueJobsPage>;
|
2026-05-29 10:27:38 -07:00
|
|
|
flushQueues(): Promise<{ success: boolean }>;
|
|
|
|
|
}
|