Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker function from @taskany/issues for reuse #777

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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))();

```
Loading
Loading