@pulzar/core
Version:
Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support
89 lines • 2.15 kB
TypeScript
import { TaskOptions, TaskResult, TaskStats, TaskAdapter } from "./types";
export interface SchedulerOptions {
adapter?: TaskAdapter;
maxConcurrency?: number;
retryAttempts?: number;
retryDelay?: number;
timeout?: number;
enableMetrics?: boolean;
}
export interface ScheduleOptions {
cron?: string;
interval?: number;
delay?: number;
repeat?: number;
timeout?: number;
retry?: boolean;
retryAttempts?: number;
retryDelay?: number;
priority?: number;
}
export declare class TaskScheduler {
private adapter;
private options;
private runningTasks;
private taskDefinitions;
constructor(options?: SchedulerOptions);
/**
* Register a task definition
*/
register(name: string, handler: Function, options?: TaskOptions): void;
/**
* Schedule a task to run
*/
schedule(name: string, data?: any, scheduleOptions?: ScheduleOptions): Promise<string>;
/**
* Execute a task immediately
*/
execute(name: string, data?: any): Promise<TaskResult>;
/**
* Cancel a scheduled task
*/
cancel(taskId: string): Promise<void>;
/**
* Get task status
*/
getStatus(taskId: string): Promise<any>;
/**
* Get all tasks
*/
getTasks(filter?: any): Promise<any[]>;
/**
* Get task statistics
*/
getStats(): Promise<TaskStats>;
/**
* Start the scheduler
*/
start(): Promise<void>;
/**
* Stop the scheduler
*/
stop(): Promise<void>;
/**
* Process scheduled tasks
*/
private processScheduledTasks;
/**
* Execute a task with retry logic
*/
private executeTask;
/**
* Execute task with retry logic
*/
private executeWithRetry;
/**
* Calculate scheduled time based on options
*/
private calculateScheduledTime;
/**
* Generate unique task ID
*/
private generateTaskId;
/**
* Delay utility
*/
private delay;
}
export declare function createTaskScheduler(options?: SchedulerOptions): TaskScheduler;
//# sourceMappingURL=scheduler.d.ts.map