mirror of
https://github.com/OptimalBits/bull.git
synced 2026-07-02 00:17:41 +08:00
docs: add missing references for job locks
This commit is contained in:
committed by
Manuel Astudillo
parent
14432ff8a5
commit
c73deb7093
+1
-1
@@ -307,5 +307,5 @@ if (nextJobdata) {
|
|||||||
**Note**
|
**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
|
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
@@ -47,8 +47,12 @@
|
|||||||
- [Job#discard](#jobdiscard)
|
- [Job#discard](#jobdiscard)
|
||||||
- [Job#promote](#jobpromote)
|
- [Job#promote](#jobpromote)
|
||||||
- [Job#finished](#jobfinished)
|
- [Job#finished](#jobfinished)
|
||||||
- [Job#moveToCompleted](#jobMoveToCompleted)
|
- [Job#moveToCompleted](#jobmovetocompleted)
|
||||||
- [Job#moveToFailed](#jobMoveToFailed)
|
- [Job#moveToFailed](#jobmovetofailed)
|
||||||
|
- [Job#lockKey](#joblockkey)
|
||||||
|
- [Job#releaseLock](#jobreleaselock)
|
||||||
|
- [Job#takeLock](#jobtakelock)
|
||||||
|
- [Job#extendLock](#jobextendlock)
|
||||||
|
|
||||||
- [Events](#events)
|
- [Events](#events)
|
||||||
- [Global events](#global-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
|
## Events
|
||||||
|
|
||||||
A queue emits also some useful events:
|
A queue emits also some useful events:
|
||||||
|
|||||||
Reference in New Issue
Block a user