Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a892ffb
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dump.rb | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# banzai-redis | ||
|
||
Redis queueing plugin module for Banzai. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var kue = require('kue') | ||
, redis = require('redis'); | ||
|
||
module.exports = function(config) { | ||
var jobs; | ||
|
||
config = config || {}; | ||
|
||
kue.redis.createClient = function() { | ||
var client = redis.createClient(config.port || 6379, config.host || '127.0.0.1'); | ||
if (config.password) { client.auth(config.password); } | ||
return client; | ||
}; | ||
|
||
jobs = kue.createQueue(); | ||
|
||
function push(type, job, done) { | ||
jobs.create(type, job).save(done); | ||
}; | ||
|
||
function pop(type, callback) { | ||
jobs.process(type, function(job, done) { | ||
callback(job.data, done); | ||
}); | ||
} | ||
|
||
return { | ||
push: push | ||
, pop: pop | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ "name" : "banzai-redis" | ||
, "description" : "Redis queueing plugin module for Banzai" | ||
, "tags" : ["ETL", "pipeline", "document", "state machine", "redis", "queue", "banzai"] | ||
, "version" : "0.1.0" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
, "repository" : | ||
{ "type" : "git" | ||
, "url" : "http://github.com/pgte/banzai-redis.git" | ||
} | ||
, "bugs" : | ||
{ "web" : "http://github.com/pgte/banzai-redis/issues" } | ||
, "engines" : ["node >= 0.4.10"] | ||
, "main" : "./index" | ||
, "dependencies": { | ||
"kue": "0.2.0" | ||
, "redis": "0.6.0" | ||
} | ||
, "scripts": { "test": "make" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var queue = require('./')() | ||
, assert = require('assert'); | ||
|
||
setTimeout(function() { | ||
process.exit(); | ||
}, 5000) | ||
|
||
exports.push_then_pop = function(done) { | ||
var job = {a: 1, b: 2} | ||
, cb1 = false; | ||
|
||
queue.push('test1', job); | ||
queue.pop('test1', function(retjob, done) { | ||
assert.ok(! cb1); | ||
assert.eql(job, retjob); | ||
cb1 = true; | ||
done(); | ||
}); | ||
|
||
done(function() { | ||
assert.ok(cb1); | ||
}) | ||
}; | ||
|
||
exports.pop_then_push = function(done) { | ||
var job = {a: 2, b: 2} | ||
, cb1 = false; | ||
|
||
queue.pop('test2', function(retjob, done) { | ||
assert.ok(! cb1); | ||
assert.eql(job, retjob); | ||
cb1 = true; | ||
done(); | ||
}); | ||
queue.push('test2', job); | ||
|
||
done(function() { | ||
assert.ok(cb1); | ||
}) | ||
}; | ||
|
||
exports.pop_no_push = function(done) { | ||
var job = {a: 3, b: 2} | ||
, cb1 = false; | ||
|
||
queue.pop('test3', function(retjob, done) { | ||
assert.ok(! cb1); | ||
assert.eql(job, retjob); | ||
cb1 = true; | ||
done(); | ||
}); | ||
|
||
done(function() { | ||
assert.ok(! cb1); | ||
}) | ||
}; |