-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
705 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
``` ts | ||
import { worker, Job } from '@taskany/bricks'; | ||
|
||
const getNextJob = // function to get first job with needed state update Status to pending, lock before updating | ||
const jobUpdate = // function to update job | ||
const jobDelete = // function to delete job | ||
const resolve = // how to resolve jobs of different kinds | ||
|
||
const onRetryLimitExeed = // what to do if retryLimit exeeded | ||
const onQueueTooLong = // what to do if queue is too long | ||
const log = // how to log info | ||
const onError = // what to do on error | ||
|
||
const defaultJobDelay = // ms between the jobs | ||
const retryLimit = // number of retryes before onRetryLimitExeed will be executed | ||
|
||
(() => | ||
setInterval(async () => { | ||
await worker( | ||
getNextJob, | ||
jobUpdate, | ||
jobDelete, | ||
resolve, | ||
onRetryLimitExeed, | ||
onQueueTooLong, | ||
log, | ||
onError, | ||
defaultJobDelay, | ||
retryLimit, | ||
); | ||
}, queueInterval))(); | ||
|
||
``` |
Oops, something went wrong.