New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

bulkhead-kue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulkhead-kue

A Bulkhead service that allows SailsJS projects to easily utilize LearnBoost's Kue.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

bulkhead-kue

A Bulkhead plugin that easily integrates LearnBoost's Kue into a SailJS project.

Installation

npm install bulkhead-kue

Then, in the config/bootstrap.js file of your SailsJS project directory, replace the default cb() with:

require('bulkhead').plugins.initialize(sails, cb);

If you are using Bulkhead-Kue with Bulkhead-Test, the suite has to be lifted like this:

var Suite = require('bulkhead-test');
Suite.lift(null, function() {
	QueueService.flush(queueName);
});

Usage

To create new jobs in a queue, do the following:

var QueueService = require('bulkhead-kue');
QueueService.create('SomeQueue', 'SomeJobType', { name: 'bob' }, function(results, job) {
	// Callback that is fired when the job is processed.
	console.log(results.name) // Outputs 'bob'
	console.log(job.id) // Outputs 1
}, function(err, results) {
	// Callback that is fired when the job is saved into the queue
	console.log(results.response().name) // Outputs 'bob'
});

NOTE:

If you create a new job on a queue that has not been created yet, .create() will create the queue as well.

To get access to the queue and it's Kue methods, do the following:

QueueService.queue('SomeQueue');

To find jobs by their processing state, the search criteria should be a string:

QueueService.find('inactive', function(err, result) {
	console.log(result.response().name); // Outputs 'bob'
});

To find jobs by their ID, the search criteria should be a number:

QueueService.find(1, function(err, result) {
	console.log(result.response().name); // Outputs 'bob'
});

To find jobs by complex criteria, the search criteria should be an object:

QueueService.find({
	type: 'SomeJobType',
	state: '*',
	from: 0,
	to: -1,
	order: 'desc'
}, function(err, result) {
	console.log(result.response().name); // Outputs 'bob'
});

To process all jobs in a queue, do the following:

QueueService.process(queueName, type, null, function(job, next) {
    // Callback that is fired per job being processed
	console.log(job.data.name) // Outputs 'bob'
	next(undefined, job.data); // Moves on to the next job to process
});

Read the official Kue documentation for more advanced usage.

Keywords

sailsjs

FAQs

Package last updated on 15 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts