Process Step Jobs
enum Step {
Initial,
Second,
Finish,
}
const worker = new Worker(
'queueName',
async job => {
let step = job.data.step;
while (step !== Step.Finish) {
switch (step) {
case Step.Initial: {
await doInitialStepStuff();
await job.updateData({
step: Step.Second,
});
step = Step.Second;
break;
}
case Step.Second: {
await doSecondStepStuff();
await job.updateData({
step: Step.Finish,
});
step = Step.Finish;
return Step.Finish;
}
default: {
throw new Error('invalid step');
}
}
}
},
{ connection },
);Delaying
Waiting Children
Chaining Flows
Read more:
Last updated
Was this helpful?