How to use the node-resque.scheduler 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 StellarFw / stellar / src / satellites / resque.js View on Github external
startScheduler (callback) {
    let self = this

    // check if the scheduler are enabled
    if (self.api.config.tasks.scheduler !== true) { return callback() }

    // get the scheduler logger
    self.schedulerLogging = self.api.config.tasks.schedulerLogging

    // create a new scheduler instance
    let Scheduler = NR.scheduler
    self.scheduler = new Scheduler({ connection: self.connectionDetails, timeout: self.api.config.tasks.timeout })

    // define the handler for the on error event
    self.scheduler.on('error', error => self.api.log(error, 'error', '[api.resque.scheduler]'))

    // start the scheduler
    self.scheduler.connect(() => {
      // define some handlers to the scheduler events
      self.scheduler.on('start', () => self.api.log('resque scheduler started', self.schedulerLogging.start))
      self.scheduler.on('end', () => self.api.log('resque scheduler ended', self.schedulerLogging.end))
      self.scheduler.on('poll', () => self.api.log('resque scheduler polling', self.schedulerLogging.poll))
      self.scheduler.on('working_timestamp', timestamp => self.api.log(`resque scheduler working timestamp ${timestamp}`, self.schedulerLogging.working_timestamp))
      self.scheduler.on('transferred_job', (timestamp, job) => self.api.log(`resque scheduler enqueuing job ${timestamp}`, self.schedulerLogging.transferred_job, job))

      // start the scheduler
      self.scheduler.start()

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