()
| 11 | } |
| 12 | |
| 13 | async beforePerform() { |
| 14 | const key = this.key(); |
| 15 | const now = Math.round(new Date().getTime() / 1000); |
| 16 | const timeout = now + this.lockTimeout() + 1; |
| 17 | |
| 18 | const lockedByMe = await this.queueObject.connection.redis.set( |
| 19 | key, |
| 20 | timeout, |
| 21 | "EX", |
| 22 | this.lockTimeout(), |
| 23 | "NX", |
| 24 | ); |
| 25 | if (lockedByMe && lockedByMe.toString().toUpperCase() === "OK") { |
| 26 | return true; |
| 27 | } else { |
| 28 | const options = this.job.pluginOptions; |
| 29 | const toReEnqueue = options?.JobLock |
| 30 | ? options.JobLock.reEnqueue !== null && |
| 31 | options.JobLock.reEnqueue !== undefined |
| 32 | ? options.JobLock.reEnqueue |
| 33 | : true |
| 34 | : true; |
| 35 | |
| 36 | if (toReEnqueue) await this.reEnqueue(); |
| 37 | return false; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | async afterPerform() { |
| 42 | const key = this.key(); |
nothing calls this directly
no test coverage detected