Queue
A queue service to run tasks in the background or schedule them to run at a certain time.
Available:
Bee
Bull
Kue
Fake
Jobs:
The structure is simple, it should be a class with a static key
method to retrieve its key and a public handle
method to perform the task. All other OOP features for distributing logic are allowed.
export class Example {
public static get key(): Capitalize<string> {
return 'Example';
}
public async handle({ data }: { data: { message: string } }): Promise<void> {
return console.log('I have a message for you: %s', data.message);
}
}
Methods:
Execute: Runs a task in the background, if it fails it repeats a certain number of times.
await this.queueProvider.execute({
job: Example,
data: {
message: 'This is the message',
},
attempts: 3,
});
Schedule: Schedules a task in the background, if it fails it repeats a certain number of times.
await this.queueProvider.schedule({
job: Example,
data: {
message: 'This is the message',
},
delay: '30min',
attempts: 3,
});
Last updated
Was this helpful?