How to use kue - 10 common examples

To help you get started, we’ve selected a few kue 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 DivanteLtd / mage2vuestorefront / src / api / routes / magento.js View on Github external
router.post('/products/update', function(req, res) { // TODO: add api key middleware

  let skus_array = req.body.sku;

  console.log('Incoming pull request for', skus_array)
  if(skus_array.length > 0){
    let queue = kue.createQueue(Object.assign(config.kue, { redis: config.redis }));

    queue.createJob('product', { skus: skus_array, adapter: 'magento' }).save();
    res.json({ status: 'done', message: 'Products ' + skus_array + ' scheduled to be refreshed'});
  } else {
    res.json({ status: 'error', message: 'Please provide product SKU separated by comma'});
  }
});
github probr / probr-analysis / server / components / tasks / tasks.js View on Github external
module.exports = function (config) {

    // Kue Job-Queue
    var kue = require('kue'), queue = kue.createQueue({
        redis: {
            port: config.redis.port,
            host: config.redis.addr
        }
    });

    var createJob = function (jobName, jobOptions, interval) {
        queue.create(jobName, jobOptions).on('complete', function (result) {
            //console.log("kue - job complete with result ", result);
            setTimeout(function () {
                createJob(jobName, jobOptions, interval);
            }, interval);

        }).on('failed attempt', function (errorMessage, doneAttempts) {
            console.log('kue - job failed ' + JSON.stringify(errorMessage));
github DivanteLtd / mage2vuestorefront / src / adapters / magento / product.js View on Github external
this.db.getDocuments('product', { query: { match: {'configurable_children.sku': item.sku } }}).then((docs) => {
              if (docs && docs.length > 0) {
                let queue = kue.createQueue(Object.assign(config.kue, { redis: config.redis }));
                docs.map(parentProduct => { // schedule for update
                  queue.createJob('product', { skus: [parentProduct.sku], adapter: 'magento' }).save();
                  logger.info('Parent product update scheduled (make sure `cli.js productsworker` queue is running)', parentProduct.sku)
                })
                opResolve(item)
              } else {
                opResolve(item)
              }
            }).catch(err => {
              logger.error(err)
github polygon-city / polygon-city-cli / workers / geojsonIndex.js View on Github external
var proj4 = require('proj4');
var turf = require('turf');
var path = require('path');
var fs = Promise.promisifyAll(require('fs-extra'));
var citygmlPoints = require('citygml-points');
var Redis = require('ioredis');

// TODO: Make this work after a crash / on resume as it currently only stores
// footprints from the current session

var redisHost = process.env.REDIS_PORT_6379_TCP_ADDR || '127.0.01';
var redisPort = process.env.REDIS_PORT_6379_TCP_PORT || 6379;

var redis = new Redis(redisPort, redisHost);

var queue = kue.createQueue({
  redis: {
    port: redisPort,
    host: redisHost,
  }
});

var exiting = false;

var getFootprint = function(xmlDOM, origin, properties) {
  properties = properties || {};

  // Find ground surfaces
  var groundSurfaces = xmldom2xml(xmlDOM.getElementsByTagName('bldg:GroundSurface'));

  // Add origin to properties
  properties.origin = origin;
github DivanteLtd / storefront-api / src / modules / default-vsf / worker / order_to_magento2.js View on Github external
/**
 * CLI tool
 * Queue worker in charge of syncing the Sales order to Magento2 via REST API *
 */

const program = require('commander');
const kue = require('kue');
const logger = require('./log');

const config = require('config')
let queue = kue.createQueue(Object.assign(config.kue, { redis: config.redis }));

let numCPUs = require('os').cpus().length;
const processSingleOrder = require('src/platform/magento2/o2m').processSingleOrder

// RUN
program
  .command('start')
  .option('--partitions ', 'number of partitions', numCPUs)
  .action((cmd) => { // default command is to run the service worker
    let partition_count = parseInt(cmd.partitions);
    logger.info(`Starting KUE worker for "order" message [${partition_count}]...`);
    queue.process('order', partition_count, (job, done) => {
      logger.info('Processing order: ' + job.data.title);
      return processSingleOrder(job.data.order, config, job, done);
    });
  });
github DivanteLtd / storefront-api / src / worker / order_to_magento2-archive.js View on Github external
/**
 * CLI tool
 * Queue worker in charge of syncing the Sales order to Magento2 via REST API * 
 */

const kue = require('kue');
const logger = require('./log');
const unirest = require('unirest');

const Ajv = require('ajv'); // json validator
const ajv = new Ajv(); // validator
const validate = ajv.compile(require('../models/order.schema.json'));

const config = require('config')
let queue = kue.createQueue(Object.assign(config.kue, { redis: config.redis }));

let numCPUs = require('os').cpus().length;

const CommandRouter = require('command-router');
const cli = CommandRouter();
cli.option({
    name: 'partitions',
      default: numCPUs,
      type: Number
  });

  /**
   * Return Magento API client
   * @param {string} method - post, put, get ...
   * @param {string} endpoint relative to /rest/V1/
   * @param {Object} addHeaders dictionary of http headers
github jivesoftware / jive-sdk / jive-sdk-api / lib / scheduler / kue / worker.js View on Github external
Worker.prototype.init = function init(handlers, options) {
    eventHandlers = handlers;
    queueName = options['queueName'];
    var self = this;
    kue.redis.createClient = function() {
        return self.makeRedisClient(options);
    };
    redisClient = self.makeRedisClient(options);
    jobs = kue.createQueue();
    jobs.promote(1000);
    jobs.process(queueName, options['concurrentJobs'] || 100, eventExecutor);
};
github firepick1 / FireREST / server / simpleq.js View on Github external
var kue = require('kue');
var jobs = kue.createQueue();

function newJob() {
    var job = jobs.create('new_job');
    job.save();
}
jobs.process('new_job', function(job, done) {
    console.log('Job', job.id, ' is done');
    done && done();
});
setInterval(newJob, 3000);
github Reportr / dashboard / lib / queue / kue.js View on Github external
var init = function() {
    logger.log("Init redis tasks queue");
    var redisURL = url.parse(config.tasks.redis);

    jobs = kue.createQueue({
        redis: {
            port: redisURL.port,
            host: redisURL.hostname,
            auth: redisURL.auth? redisURL.auth.split(":")[1] : null,
            options: {
                no_ready_check: true
            }
        }
    });
};
github darielnoel / kue-cleanup / lib / kue-cleanup.js View on Github external
init: function(config) {
            var instance = KueCleanup;

            instance.config = config || {};

            jobs = kue.createQueue(instance.config);

            instance.setupJobs(instance.config);
        },

kue

Feature rich priority job queue backed by redis

MIT
Latest version published 8 years ago

Package Health Score

56 / 100
Full package analysis

Popular kue functions