docs: add missing references for job locks

This commit is contained in:
Antony K. S
2023-10-19 10:01:24 +07:00
committed by Manuel Astudillo
parent 14432ff8a5
commit c73deb7093
2 changed files with 46 additions and 3 deletions
+1 -1
View File
@@ -307,5 +307,5 @@ if (nextJobdata) {
**Note**
By default the lock duration for a job that has been returned by ```getNextJob``` or ```moveToCompleted``` is 30 seconds, if it takes more time than that the job will be automatically
marked as stalled and depending on the max stalled options be moved back to the wait state or marked as failed. In order to avoid this you must use ```job.extendLock(duration)``` in order to give you some more time before the lock expires. The recommended is to extend the lock when half the lock time has passsed.
marked as stalled and depending on the max stalled options be moved back to the wait state or marked as failed. In order to avoid this you must use [```job.extendLock(duration)```](REFERENCE.md#jobextendlock) in order to give you some more time before the lock expires. The recommended is to extend the lock when half the lock time has passsed.
+45 -2
View File
@@ -47,8 +47,12 @@
- [Job#discard](#jobdiscard)
- [Job#promote](#jobpromote)
- [Job#finished](#jobfinished)
- [Job#moveToCompleted](#jobMoveToCompleted)
- [Job#moveToFailed](#jobMoveToFailed)
- [Job#moveToCompleted](#jobmovetocompleted)
- [Job#moveToFailed](#jobmovetofailed)
- [Job#lockKey](#joblockkey)
- [Job#releaseLock](#jobreleaselock)
- [Job#takeLock](#jobtakelock)
- [Job#extendLock](#jobextendlock)
- [Events](#events)
- [Global events](#global-events)
@@ -1009,6 +1013,45 @@ Moves a job to the `failed` queue. Pulls a job from 'waiting' to 'active' and re
---
### Job#lockKey
```ts
lockKey(): string
```
Return a unique key representing a lock for this Job.
---
### Job#releaseLock
```ts
releaseLock(): Promise<void>
```
Releases the lock on the job. Only locks owned by the queue instance can be released.
---
### Job#takeLock
```ts
takeLock(): Promise<number | false>
```
Takes a lock for this job so that no other queue worker can process it at the same time.
---
### Job#extendLock
```ts
extendLock(duration: number): Promise<number>
```
Extend the lock for this job. The `duration` parameter specifies the lock duration in milliseconds. It will return '1' on success and '0' on failure.
---
## Events
A queue emits also some useful events: