UNPKG

@fellas/adonisjs-resque

Version:
52 lines (51 loc) 1.75 kB
import { ResqueFailure } from "./types.js"; import { Logger } from "@adonisjs/core/logger"; import { Plugin } from "node-resque"; export default class BaseJob { interval?: string | number; cron?: string; plugins: [typeof Plugin, any][]; delayMs: number; runAtMs?: number; /** * the default JobName is this class name * it **MUST be a unique name** */ jobName?: string; /** * set a queueName for this job * default configured in `config/resque.ts` */ queueName?: string; args: any[]; allArgs: any[][]; hasEnqueued: boolean; hasEnqueuedAll: boolean; app: import("@adonisjs/core/types").ApplicationService; logger: Logger; constructor(..._args: any[]); private createLogger; static enqueue<T extends typeof BaseJob>(this: T, ...args: Parameters<T['prototype']['perform']>): BaseJob; enqueue<T extends BaseJob>(this: T, ...args: Parameters<T['perform']>): T; static queue(queueName: string): BaseJob; queue(queueName: string): this; static enqueueAll<T extends typeof BaseJob>(this: T, args: Parameters<T['prototype']['perform']>[]): BaseJob; enqueueAll<T extends BaseJob>(this: T, args: Parameters<T['perform']>[]): T; static in(ms: number): BaseJob; in(ms: number): this; static at(ms: number): BaseJob; at(ms: number): this; perform(..._args: any[]): any; handleError(error: unknown): void; onFailure(_failure: ResqueFailure): void | Promise<void>; private execute; /** * this method runs after an `await` statement * e.g, * ```typescript * await job.enqueue().in(2000) * ``` * @param fn */ then(fn: (result: void | boolean | boolean[]) => void): void; }