()
| 858 | } |
| 859 | |
| 860 | _activateDelayed() { |
| 861 | if (!this.settings.activateDelayedJobs) return; |
| 862 | this._evalScript( |
| 863 | 'raiseDelayedJobs', |
| 864 | 2, |
| 865 | this.toKey('delayed'), |
| 866 | this.toKey('waiting'), |
| 867 | Date.now(), |
| 868 | this.settings.delayedDebounce |
| 869 | ).then( |
| 870 | (results) => { |
| 871 | const numRaised = results[0], |
| 872 | nextOpportunity = results[1]; |
| 873 | if (numRaised) { |
| 874 | this.emit('raised jobs', numRaised); |
| 875 | } |
| 876 | this._delayedTimer.schedule(parseInt(nextOpportunity, 10)); |
| 877 | }, |
| 878 | /* istanbul ignore next */ (err) => { |
| 879 | // Handle aborted redis connections. |
| 880 | if (redis.isAbortError(err)) { |
| 881 | if (this.paused) return; |
| 882 | // Retry. |
| 883 | return this._activateDelayed(); |
| 884 | } |
| 885 | this._emitErrorAfterTick(err); |
| 886 | } |
| 887 | ); |
| 888 | } |
| 889 | |
| 890 | toKey(str) { |
| 891 | return this.settings.keyPrefix + str; |
no test coverage detected