@cleotasks/core
Version:
A distributed task queue system for Node.js, inspired by Celery and BullMQ
54 lines (53 loc) • 1.76 kB
TypeScript
import { RedisInstance } from "../config/redis";
import { TaskHistoryEntry } from "../types/interfaces";
export interface ExtendedTaskHistoryEntry extends TaskHistoryEntry {
workerId?: string;
queueName?: string;
}
export declare class TaskHistoryService {
private redis;
private static instances;
private constructor();
static getInstance(instanceId?: RedisInstance): TaskHistoryService;
/**
* Add a task history entry
*/
addTaskHistory(taskId: string, status: string, duration: number, workerId: string, queueName: string, error?: any, group?: string): Promise<void>;
/**
* Get task history for a specific worker
*/
getWorkerHistory(workerId: string, limit?: number): Promise<ExtendedTaskHistoryEntry[]>;
/**
* Get task history for a specific task
*/
getTaskHistory(taskId: string, limit?: number): Promise<ExtendedTaskHistoryEntry[]>;
/**
* Get global task history
*/
getGlobalHistory(limit?: number): Promise<ExtendedTaskHistoryEntry[]>;
/**
* Get task history for a specific queue
*/
getQueueHistory(queueName: string, limit?: number): Promise<ExtendedTaskHistoryEntry[]>;
/**
* Get task history for a specific group
*/
getGroupHistory(group: string, limit?: number): Promise<ExtendedTaskHistoryEntry[]>;
/**
* Get task history statistics
*/
getHistoryStats(): Promise<{
totalTasks: number;
completedTasks: number;
failedTasks: number;
averageDuration: number;
}>;
/**
* Clear task history for a specific worker
*/
clearWorkerHistory(workerId: string): Promise<void>;
/**
* Clear all task history
*/
clearAllHistory(): Promise<void>;
}