lib/Queue.js
/**
   *  Subscribe creates an alternate redis client to use pub/sub commands.
   *  A redis client using pub/sub will lose access to all other method,
   *  so that's why we need to create a new client.
   */
Subscribe creates an alternate redis client to use pub/sub commands.
A redis client using pub/sub will lose access to all other method,
so that's why we need to create a new client.
Subscribe creates an alternate redis client to use pub / sub commands . A redis client using pub / sub will lose access to all other method so that ' s why we need to create a new client .
subscribe() {
    const TIMEOUT = 1 * 1000; 
    return new Promise((resolve, reject) => {
      const timeout = setTimeout(() => {
        reject(new Error(`Subscribe timeout after ${TIMEOUT / 1000}s`));
      }, TIMEOUT);
      this.subclient = Redis.createClient(this.opts.port, this.opts.host, {
        ...this.opts.options,
        retry_strategy: (log) => {
          if (log.error) {
            reject(log.error);
            return undefined;
          }
          return 3000;
        },
      });
      this.subclient.once('connect', () => {
        this.subclient.subscribe(this.name);
        this.subclient.once('subscribe', (channel, count) => {
          clearTimeout(timeout);
          resolve(count);
        });
        this.subclient.on('message', (channel, message) => {
          this.emit('message', message);
        });
      });
    });
  }
subscribe ( ) { const TIMEOUT = 1 * 1000 ; return new Promise ( ( resolve , reject ) => { const timeout = setTimeout ( ( ) => { reject ( new Error ( ` ${ TIMEOUT / 1000 } ` ) ) ; } , TIMEOUT ) ; this . subclient = Redis . createClient ( this . opts . port , this . opts . host , { ... this . opts . options , retry_strategy : ( log ) => { if ( log . error ) { reject ( log . error ) ; return undefined ; } return 3000 ; } , } ) ; this . subclient . once ( 'connect' , ( ) => { this . subclient . subscribe ( this . name ) ; this . subclient . once ( 'subscribe' , ( channel , count ) => { clearTimeout ( timeout ) ; resolve ( count ) ; } ) ; this . subclient . on ( 'message' , ( channel , message ) => { this . emit ( 'message' , message ) ; } ) ; } ) ; } ) ; }
Subscribe creates an alternate redis client to use pub/sub commands.
Subscribe creates an alternate redis client to use pub / sub commands .
// 1 second