Configuring Queues
When specifying a queue, you can optionally pass an options
object to customize the queue's behavior.
There's currently 1 option you can customize:
maxAttempts
- Default is 1. Increasing this means your job will be retried untilcurrentAttempt <= maxAttempts
.
maxAttempts
By increasing the maxAttempts
for a job, you are allowing the job to be retried in the future. All jobs have a default maxAttempts
of 1, so if you want a job to run at most 5 times before being marked as failed, you can set maxAttempts to 5.
ts
import {Sidetrack } from "sidetrack";constsidetrack = newSidetrack <{userOnboarding : {}>({databaseOptions : {connectionString :process .env ["DATABASE_URL"]!,},queues : {userOnboarding : {handler : async (job ) => {throw newError ("intentionally failing job");},options : {maxAttempts : 5,},},},});sidetrack .start ();sidetrack .insertJob ("userOnboarding", {
ts
import {Sidetrack } from "sidetrack";constsidetrack = newSidetrack <{userOnboarding : {}>({databaseOptions : {connectionString :process .env ["DATABASE_URL"]!,},queues : {userOnboarding : {handler : async (job ) => {throw newError ("intentionally failing job");},options : {maxAttempts : 5,},},},});sidetrack .start ();sidetrack .insertJob ("userOnboarding", {
This job will fail on the first run then move to retrying
status since its currentAttempt
(1) is less than 5. After 5 attempts, the job will transition to a status of failed
.