How to use the node-resque.queue 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-combined.js View on Github external
var email    = {
    to:      decodeURI(urlParts[1]),
    subject: decodeURI(urlParts[2]),
    text:    decodeURI(urlParts[3]),
  };

  queue.enqueue('emailQueue', "sendEmail", email, function(error){
    console.log('email :' + JSON.stringify(email));
    if(error){ console.log(error) }
    var response = {email: email};
    res.writeHead(200, {'Content-Type': 'application/json'});
    res.end(JSON.stringify(response, null, 2));
  });
};

var queue = new NR.queue({connection: connectionDetails}, jobs);
queue.connect(function(){
  http.createServer(server).listen(httpPort, httpHost);
  console.log('Server running at ' + httpHost + ':' + httpPort);
  console.log('send an email and message to /TO_ADDRESS/SUBJECT/YOUR_MESSAGE');
});

///////////////////
// RESQUE WORKER //
///////////////////

var worker = new NR.worker({connection: connectionDetails, queues: ['emailQueue']}, jobs);
worker.connect(function(){
  worker.workerCleanup();
  worker.start();
});
github evantahler / background_jobs_node / 5-multiWorkerResque.js View on Github external
"slowCPUJob": {
    plugins: [],
    pluginOptions: {},
    perform: function(callback){
      var start = new Date().getTime();
      blockingSleep(1000);
      callback(null, (new Date().getTime() - start) );
    },
  },
};

///////////////////
// ENQUEUE TASKS //
///////////////////

var queue = new NR.queue({connection: connectionDetails}, jobs);
queue.connect(function(){
  var i;
  i = 0;
  while(i < 10){
    queue.enqueue('slowQueue', "slowCPUJob", []);
    i++;
  }

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

//////////
github koopjs / koop-provider-agol / models / feature-queue.js View on Github external
var log = options.log
    var work = new Work(options)
    if (!options.connection) {
      return {
        enqueue: function (foo, bar, job) {
          doLocal(work, job)
        },
        removeFailed: function () {},
        failed: function () {},
        length: function () {},
        allWorkingOn: function () {}
      }
    }
    var connection = work.connection
    connection.pkg = 'redis'
    var queue = new Resque({connection: connection}, work.jobs)

    process.on('SIGINT', function () {
      queue.end(function () {
        process.exit()
      })
    })

    process.on('SIGTERM', function () {
      queue.end(function () {
        process.exit()
      })
    })

    queue.connect(function () {
      setInterval(function () {
        log.info('Clearing old workers from the queue')
github OpenNeuroOrg / openneuro / server / libs / queue / index.js View on Github external
const connect = async redis => {
  if (!queue) {
    queue = new NR.queue({ connection: { redis: redis } }, tasks)
    await queue.connect()
  }
  return queue
}

node-resque

an opinionated implementation of resque in node

Apache-2.0
Latest version published 5 months ago

Package Health Score

80 / 100
Full package analysis