import { ID } from '@subit/common/lib/shared-types'; import { InjectableJobQueueStrategy } from './injectable-job-queue-strategy'; import { Job } from './job'; import { JobData } from './types'; /** * @description * Defines the backoff strategy used when retrying failed jobs. Returns the delay in * ms that should pass before the failed job is retried. * * @docsCategory JobQueue * @docsPage types */ export declare type BackoffStrategy = (queueName: string, attemptsMade: number, job: Job) => number; export interface PollingJobQueueStrategyConfig { concurrency?: number; pollInterval?: number | ((queueName: string) => number); backoffStrategy?: BackoffStrategy; } /** * @description * This class allows easier implementation of {@link JobQueueStrategy} in a polling style. * Instead of providing {@link JobQueueStrategy} `start()` you should provide a `next` method. * * This class should be extended by any strategy which does not support a push-based system * to notify on new jobs. It is used by the {@link SqlJobQueueStrategy} and {@link InMemoryJobQueueStrategy}. * * @docsCategory JobQueue */ export declare abstract class PollingJobQueueStrategy extends InjectableJobQueueStrategy { concurrency: number; pollInterval: number | ((queueName: string) => number); backOffStrategy?: BackoffStrategy; private activeQueues; constructor(config?: PollingJobQueueStrategyConfig); constructor(concurrency?: number, pollInterval?: number); start = {}>(queueName: string, process: (job: Job) => Promise): Promise; stop = {}>(queueName: string, process: (job: Job) => Promise): Promise; cancelJob(jobId: ID): Promise; /** * @description * Should return the next job in the given queue. The implementation is * responsible for returning the correct job according to the time of * creation. */ abstract next(queueName: string): Promise; /** * @description * Update the job details in the store. */ abstract update(job: Job): Promise; /** * @description * Returns a job by its id. */ abstract findOne(id: ID): Promise; }