Skip to content

Commit

Permalink
bump to 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
behrad committed Jan 20, 2014
1 parent 5c43477 commit 356a314
Show file tree
Hide file tree
Showing 53 changed files with 3,574 additions and 1,186 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .npmignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified History.md
100644 → 100755
Empty file.
38 changes: 19 additions & 19 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ REPORTER = spec
all: build

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

test-tdd:
@./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--ui tdd \
test/tdd/*.js
@./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--ui tdd \
test/tdd/*.js

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

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


test-all: test-bdd test-tdd test-bdd-coffee

.PHONY: test-all
.PHONY: test-all
Empty file modified Readme.md
100644 → 100755
Empty file.
33 changes: 14 additions & 19 deletions examples/delayed.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var kue = require('../');

// create our job queue
Expand All @@ -10,36 +9,32 @@ var jobs = kue.createQueue();
var minute = 60000;

var email = jobs.create('email', {
title: 'Account renewal required'
, to: '[email protected]'
, template: 'renewal-email'
title: 'Account renewal required', to: '[email protected]', template: 'renewal-email'
}).delay(minute)
.priority('high')
.save();
.priority('high')
.save();


email.on('promotion', function(){
console.log('renewal job promoted');
email.on('promotion', function () {
console.log('renewal job promoted');
});

email.on('complete', function(){
console.log('renewal job completed');
email.on('complete', function () {
console.log('renewal job completed');
});

jobs.create('email', {
title: 'Account expired'
, to: '[email protected]'
, template: 'expired-email'
title: 'Account expired', to: '[email protected]', template: 'expired-email'
}).delay(minute * 10)
.priority('high')
.save();
.priority('high')
.save();

jobs.promote();

jobs.process('email', 10, function(job, done){
setTimeout(function(){
done();
}, Math.random() * 5000);
jobs.process('email', 10, function (job, done) {
setTimeout(function () {
done();
}, Math.random() * 5000);
});

// start the UI
Expand Down
67 changes: 32 additions & 35 deletions examples/events.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var kue = require('../');

// create our job queue
Expand All @@ -13,49 +12,47 @@ var jobs = kue.createQueue();
// user input etc.

function create() {
var name = ['tobi', 'loki', 'jane', 'manny'][Math.random() * 4 | 0];
var job = jobs.create('video conversion', {
title: 'converting ' + name + '\'s to avi'
, user: 1
, frames: 200
});

job.on('complete', function(){
console.log(" Job complete");
}).on('failed', function(){
console.log(" Job failed");
}).on('progress', function(progress){
process.stdout.write('\r job #' + job.id + ' ' + progress + '% complete');
});

job.save();

setTimeout(create, Math.random() * 2000 | 0);
var name = ['tobi', 'loki', 'jane', 'manny'][Math.random() * 4 | 0];
var job = jobs.create('video conversion', {
title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
});

job.on('complete',function () {
console.log(" Job complete");
}).on('failed',function () {
console.log(" Job failed");
}).on('progress', function (progress) {
process.stdout.write('\r job #' + job.id + ' ' + progress + '% complete');
});

job.save();

setTimeout(create, Math.random() * 2000 | 0);
}

create();

// process video conversion jobs, 1 at a time.

jobs.process('video conversion', 1, function(job, done){
var frames = job.data.frames;

function next(i) {
// pretend we are doing some work
convertFrame(i, function(err){
if (err) return done(err);
// report progress, i/frames complete
job.progress(i, frames);
if (i >= frames) done()
else next(i + Math.random() * 10);
});
}

next(0);
jobs.process('video conversion', 1, function (job, done) {
var frames = job.data.frames;

function next(i) {
// pretend we are doing some work
convertFrame(i, function (err) {
if (err) return done(err);
// report progress, i/frames complete
job.progress(i, frames);
if (i >= frames) done()
else next(i + Math.random() * 10);
});
}

next(0);
});

function convertFrame(i, fn) {
setTimeout(fn, Math.random() * 50);
setTimeout(fn, Math.random() * 50);
}

// start the UI
Expand Down
38 changes: 17 additions & 21 deletions examples/many.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@

var kue = require('../')
, express = require('express');
, express = require('express');

// create our job queue

var jobs = kue.createQueue();

function create() {
var name = ['tobi', 'loki', 'jane', 'manny'][Math.random() * 4 | 0];
jobs.create('video conversion', {
title: 'converting ' + name + '\'s to avi'
, user: 1
, frames: 200
}).save();
setTimeout(create, Math.random() * 3000 | 0);
var name = ['tobi', 'loki', 'jane', 'manny'][Math.random() * 4 | 0];
jobs.create('video conversion', {
title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
}).save();
setTimeout(create, Math.random() * 3000 | 0);
}

create();

function create2() {
var name = ['tobi', 'loki', 'jane', 'manny'][Math.random() * 4 | 0];
jobs.create('email', {
title: 'emailing ' + name + ''
, body: 'hello'
}).save();
setTimeout(create2, Math.random() * 1000 | 0);
var name = ['tobi', 'loki', 'jane', 'manny'][Math.random() * 4 | 0];
jobs.create('email', {
title: 'emailing ' + name + '', body: 'hello'
}).save();
setTimeout(create2, Math.random() * 1000 | 0);
}

create2();

// process video conversion jobs, 3 at a time.

jobs.process('video conversion', 2, function(job, done){
console.log('video');
setTimeout(done, Math.random() * 5000);
jobs.process('video conversion', 2, function (job, done) {
console.log('video');
setTimeout(done, Math.random() * 5000);
});

// process 10 emails at a time

jobs.process('email', 10, function(job, done){
console.log('email');
setTimeout(done, Math.random() * 2000);
jobs.process('email', 10, function (job, done) {
console.log('email');
setTimeout(done, Math.random() * 2000);
});

// start the UI
Expand Down
37 changes: 18 additions & 19 deletions examples/shutdown.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@

var kue = require('../')

var jobs = kue.createQueue()


function generateJobs() {
for (var i=0; i<12; i++) {
console.log('Creating Job #' + i);
jobs.create('long render', {
title: 'rendering frame #' + i
}).save();
}
for (var i = 0; i < 12; i++) {
console.log('Creating Job #' + i);
jobs.create('long render', {
title: 'rendering frame #' + i
}).save();
}
}


jobs.process('long render', 4, function(job, done) {
console.log('Starting ' + job.data.title);
setTimeout(function() {
console.log('Finished ' + job.data.title);
done();
}, 3000);
jobs.process('long render', 4, function (job, done) {
console.log('Starting ' + job.data.title);
setTimeout(function () {
console.log('Finished ' + job.data.title);
done();
}, 3000);
})


generateJobs();

setTimeout(function() {
console.log('[ Shutting down when all jobs finish... ]');
jobs.shutdown(function(err) {
console.log('[ All jobs finished. Kue is shut down. ]');
process.exit(0);
})
setTimeout(function () {
console.log('[ Shutting down when all jobs finish... ]');
jobs.shutdown(function (err) {
console.log('[ All jobs finished. Kue is shut down. ]');
process.exit(0);
})
}, 4200)

Loading

0 comments on commit 356a314

Please sign in to comment.