MCPcopy Index your code
hub / github.com/bee-queue/bee-queue / _waitForJob

Method _waitForJob

lib/queue.js:499–532  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

497 }
498
499 _waitForJob() {
500 return helpers
501 .callAsync((done) =>
502 this.bclient.brpoplpush(
503 this.toKey('waiting'),
504 this.toKey('active'),
505 0,
506 done
507 )
508 )
509 .then(
510 (jobId) =>
511 // Note that the job may be null in the case that the client has
512 // removed the job before processing can take place, but after the
513 // brpoplpush has returned the job id.
514 Job.fromId(this, jobId),
515 (err) => {
516 if (redis.isAbortError(err) && this.paused) {
517 return null;
518 }
519
520 this.emit('error', err);
521
522 // Retry the brpoplpush after a delay
523 this._redisFailureRetryDelay = this._redisFailureRetryDelay
524 ? this._redisFailureRetryDelay * 2
525 : this.settings.initialRedisFailureRetryDelay;
526
527 return helpers
528 .delay(this._redisFailureRetryDelay)
529 .then(() => this._waitForJob());
530 }
531 );
532 }
533
534 _getNextJob() {
535 this._redisFailureRetryDelay = 0;

Callers 1

_getNextJobMethod · 0.95

Calls 2

toKeyMethod · 0.95
fromIdMethod · 0.80

Tested by

no test coverage detected