Skip to content

Commit

Permalink
feat: worker script
Browse files Browse the repository at this point in the history
  • Loading branch information
nyet-ty committed Feb 1, 2024
1 parent 8cb6919 commit f21e5c4
Show file tree
Hide file tree
Showing 5 changed files with 704 additions and 176 deletions.
33 changes: 33 additions & 0 deletions docs/workerExample.md
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 jobUpdate = // function to delete job
const resolve = // how to resolve jobs of different kinds

const onRetryLimitExeed = // what to do if retryLimit exeeded
const onQueeTooLong = // what to do if quee 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,
onQueeTooLong,
log,
onError,
defaultJobDelay,
retryLimit,
);
}, queueInterval))();

```
Loading

0 comments on commit f21e5c4

Please sign in to comment.