How to use the node-resque.multiWorker function in node-resque

To help you get started, we’ve selected a few node-resque examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evantahler / background_jobs_node / 5-multiWorkerResque.js View on Github external
i++;
  }

  i = 0;
  while(i < 500){
    queue.enqueue('slowQueue', "slowSleepJob", []);
    i++;
  }
});

//////////
// WORK //
//////////


var multiWorker = new NR.multiWorker({
  connection: connectionDetails,
  queues: ['slowQueue'],
  minTaskProcessors: 1,
  maxTaskProcessors: 20,
}, jobs);

// normal worker emitters
multiWorker.on('start',             function(workerId){                      console.log("worker["+workerId+"] started"); });
multiWorker.on('end',               function(workerId){                      console.log("worker["+workerId+"] ended"); });
multiWorker.on('cleaning_worker',   function(workerId, worker, pid){         console.log("cleaning old worker " + worker); });
multiWorker.on('poll',              function(workerId, queue){               console.log("worker["+workerId+"] polling " + queue); });
multiWorker.on('job',               function(workerId, queue, job){          console.log("worker["+workerId+"] working job " + queue + " " + JSON.stringify(job)); });
multiWorker.on('reEnqueue',         function(workerId, queue, job, plugin){  console.log("worker["+workerId+"] reEnqueue job (" + plugin + ") " + queue + " " + JSON.stringify(job)); });
multiWorker.on('success',           function(workerId, queue, job, result){  console.log("worker["+workerId+"] job success " + queue + " " + JSON.stringify(job) + " >> " + result); });
multiWorker.on('failure',           function(workerId, queue, job, failure){ console.log("worker["+workerId+"] job failure " + queue + " " + JSON.stringify(job) + " >> " + failure); });
multiWorker.on('error',             function(workerId, queue, job, error){   console.log("worker["+workerId+"] error " + queue + " " + JSON.stringify(job) + " >> " + error); });
github StellarFw / stellar / src / satellites / resque.js View on Github external
startMultiWorker (callback) {
    let self = this

    self.workerLogging = self.api.config.tasks.workerLogging
    self.schedulerLogging = self.api.config.tasks.schedulerLogging

    // create a new multiworker instance
    let MultiWorker = NR.multiWorker
    self.multiWorker = new MultiWorker({
      connection: self.connectionDetails,
      queues: self.api.config.tasks.queues,
      timeout: self.api.config.tasks.timeout,
      checkTimeout: self.api.config.tasks.checkTimeout,
      minTaskProcessors: self.api.config.tasks.minTaskProcessors,
      maxTaskProcessors: self.api.config.tasks.maxTaskProcessors,
      maxEventLoopDelay: self.api.config.tasks.maxEventLoopDelay,
      toDisconnectProcessors: self.api.config.tasks.toDisconnectProcessors
    }, self.api.tasks.jobs)

    // normal worker emitters
    self.multiWorker.on('start', workerId => self.api.log('worker: started', self.workerLogging.start, { workerId: workerId }))
    self.multiWorker.on('end', workerId => self.api.log('worker: ended', self.workerLogging.end, { workerId: workerId }))
    self.multiWorker.on('cleaning_worker', (workerId, worker, pid) => self.api.log(`worker: cleaning old worker ${worker}, (${pid})`, self.workerLogging.cleaning_worker))
    // for debug: self.multiWorker.on('poll', (queue) => self.api.log(`worker: polling ${queue}`, self.workerLogging.poll))
github koopjs / koop-provider-agol / worker.js View on Github external
log: koop.log,
  cache: koop.cache
}
var cache = new Cache(cacheOpts)

var workOpts = {
  connection: config.queue.connection,
  cache: cache,
  log: koop.log,
  files: koop.fs,
  queue: koop.queue
}

var work = new Work(workOpts)

var multiWorker = new MultiWorker({
  connection: work.connection,
  queues: ['agol'],
  minTaskProcessors: 10,
  maxTaskProcessors: 100,
  checkTimeout: 1000,
  maxEventLoopDelay: 10,
  toDisconnectProcessors: true
}, work.jobs)

multiWorker.start()

multiWorker.on('start', function (workerId) {
  koop.log.info('worker[' + workerId + '] started')
})
multiWorker.on('end', function (workerId) {
  koop.log.info('worker[' + workerId + '] ended')

node-resque

an opinionated implementation of resque in node

Apache-2.0
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis