JobQueueStrategy

JobQueueStrategy

JobQueueStrategy

Defines how the jobs in the JobQueueService are persisted and accessed. Custom strategies can be defined to make use of external services such as Redis.

Signature

interface JobQueueStrategy extends InjectableStrategy {
  add(job: Job): Promise<Job>;
  next(queueName: string): Promise<Job | undefined>;
  update(job: Job): Promise<void>;
  findOne(id: ID): Promise<Job | undefined>;
  findMany(options?: JobListOptions): Promise<PaginatedList<Job>>;
  findManyById(ids: ID[]): Promise<Job[]>;
  removeSettledJobs(queueNames?: string[], olderThan?: Date): Promise<number>;
}

Extends

Members

add

method
type:
(job: Job) => Promise<Job>
Add a new job to the queue.

next

method
type:
(queueName: string) => Promise<Job | undefined>
Should return the next job in the given queue. The implementation is responsible for returning the correct job according to the time of creation.

update

method
type:
(job: Job) => Promise<void>
Update the job details in the store.

findOne

method
type:
(id: ID) => Promise<Job | undefined>
Returns a job by its id.

findMany

method
type:
(options?: JobListOptions) => Promise<PaginatedList<Job>>
Returns a list of jobs according to the specified options.

findManyById

method
type:
(ids: ID[]) => Promise<Job[]>
Returns an array of jobs for the given ids.

removeSettledJobs

method
type:
(queueNames?: string[], olderThan?: Date) => Promise<number>

Remove all settled jobs in the specified queues older than the given date. If no queueName is passed, all queues will be considered. If no olderThan date is passed, all jobs older than the current time will be removed.

Returns a promise of the number of jobs removed.