Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1188

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Dev #1188

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
*.rdb
test/incomplete
*.swp
/.project
Empty file modified .npmignore
100755 → 100644
Empty file.
Empty file modified .travis.yml
100755 → 100644
Empty file.
Empty file modified History.md
100755 → 100644
Empty file.
7 changes: 5 additions & 2 deletions Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ all: build

build:
@./node_modules/coffee-script/bin/coffee \
--exit \
-c \
-o lib src

test-tdd:
@./node_modules/.bin/mocha \
--exit \
--reporter $(REPORTER) \
--require should \
--require sinon \
Expand All @@ -17,17 +19,18 @@ test-tdd:

test-bdd:
@./node_modules/.bin/mocha \
--exit \
--reporter $(REPORTER) \
--require should \
--ui bdd \
test/*.js

test-bdd-coffee:
@./node_modules/.bin/mocha \
--compilers coffee:coffee-script \
--exit \
--reporter $(REPORTER) \
--require should \
--require coffee-script/register \
--require should \
--ui bdd \
test/*.coffee

Expand Down
10 changes: 5 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ queue.on('job enqueue', function(id, type){
console.log( 'Job %s got queued of type %s', id, type );

}).on('job complete', function(id, result){
kue.Job.get(id, function(err, job){
queue.Job.get(id, function(err, job){
if (err) return;
job.remove(function(err){
if (err) throw err;
Expand Down Expand Up @@ -490,14 +490,14 @@ queue.inactive( function( err, ids ) { // others are active, complete, failed, d
however the second one doesn't scale to large deployments, there you can use more specific `Job` static methods:

```js
kue.Job.rangeByState( 'failed', 0, n, 'asc', function( err, jobs ) {
queue.Job.rangeByState( 'failed', 0, n, 'asc', function( err, jobs ) {
// you have an array of maximum n Job objects here
});
```
or

```js
kue.Job.rangeByType( 'my-job-type', 'failed', 0, n, 'asc', function( err, jobs ) {
queue.Job.rangeByType( 'my-job-type', 'failed', 0, n, 'asc', function( err, jobs ) {
// you have an array of maximum n Job objects here
});
```
Expand All @@ -512,7 +512,7 @@ If you did none of above in [Error Handling](#error-handling) section or your pr
```js
queue.active( function( err, ids ) {
ids.forEach( function( id ) {
kue.Job.get( id, function( err, job ) {
queue.Job.get( id, function( err, job ) {
// Your application should check if job is a stuck one
job.inactive();
});
Expand All @@ -533,7 +533,7 @@ queue.create( ... ).removeOnComplete( true ).save()
But if you eventually/temporally need completed job data, you can setup an on-demand job removal script like below to remove top `n` completed jobs:

```js
kue.Job.rangeByState( 'complete', 0, n, 'asc', function( err, jobs ) {
queue.Job.rangeByState( 'complete', 0, n, 'asc', function( err, jobs ) {
jobs.forEach( function( job ) {
job.remove( function(){
console.log( 'removed ', job.id );
Expand Down
20 changes: 10 additions & 10 deletions bin/kue-dashboard
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env node
var kue = require('kue');
var argv = require('yargs')
.usage('Usage: $0 [options]')
.example('$0 -p 3050 -r redis://10.0.0.4:6379 -q q')
.describe('r', 'Redis url')
.describe('p', 'Dashboard port')
.describe('q', 'Prefix to use')
.default('p', 3000)
.default('r', 'redis://127.0.0.1:6379')
.default('q', 'q')
.help('h')
.usage('Usage: $0 [options]')
.example('$0 -p 3050 -r redis://10.0.0.4:6379 -q q')
.describe('r', 'Redis url')
.describe('p', 'Dashboard port')
.describe('q', 'Prefix to use')
.default('p', 3000)
.default('r', 'redis://127.0.0.1:6379')
.default('q', 'q')
.help('h')
.alias('h', 'help')
.argv
;

kue.createQueue({
kue.getQueue({
redis: argv.r,
prefix: argv.q
});
Expand Down
4 changes: 2 additions & 2 deletions examples/stale.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var kue = require( '../' )
// create our job queue

var jobs = kue.createQueue()
, Job = kue.Job;
, Job = jobs.Job;

// start redis with $ redis-server

Expand Down Expand Up @@ -62,4 +62,4 @@ jobs.on( 'job complete', function ( id ) {
var app = express.createServer();
app.use( kue.app );
app.listen( 3000 );
console.log( 'UI started on port 3000' );
console.log( 'UI started on port 3000' );
Empty file modified index.js
100755 → 100644
Empty file.
3 changes: 1 addition & 2 deletions lib/http/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
*/

var Queue = require('../../kue')
, Job = require('../../queue/job')
, queue = Queue.createQueue();
, queue = Queue.getQueue();

/**
* Serve the index page.
Expand Down
10 changes: 5 additions & 5 deletions lib/http/routes/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/

var Queue = require('../../kue')
, Job = require('../../queue/job')
, lodash = require('lodash')
, queue = Queue.createQueue();
, queue = Queue.getQueue()
, Job = queue.Job;

/**
* Search instance.
Expand All @@ -21,7 +21,7 @@ var search;
function getSearch() {
if( search ) return search;
var reds = require('reds');
reds.createClient = require('../../redis').createClient;
reds.createClient = queue.redis.createClient;
return search = reds.createSearch(queue.client.getKey('search'));
}

Expand Down Expand Up @@ -158,7 +158,7 @@ exports.createJob = function( req, res ) {
function _create( args, next ) {
if( !args.type ) return next({ error: 'Must provide job type' }, null, 400);

var job = new Job(args.type, args.data || {});
var job = queue.createJob(args.type, args.data || {});
var options = args.options || {};
if( options.attempts ) job.attempts(parseInt(options.attempts));
if( options.priority ) job.priority(options.priority);
Expand All @@ -167,7 +167,7 @@ exports.createJob = function( req, res ) {
if( options.backoff ) job.backoff(options.backoff);
if( options.removeOnComplete ) job.removeOnComplete(options.removeOnComplete);
if( options.ttl ) job.ttl(options.ttl);

job.save(function( err ) {
if( err ) {
return next({ error: err.message }, null, 500);
Expand Down
Loading