From fa6f3d4bb03bd58592bbf6461f3be20930457fd4 Mon Sep 17 00:00:00 2001 From: Mani Fazeli Date: Fri, 22 Jun 2012 15:11:23 -0400 Subject: [PATCH 1/5] Fixed missing redis requirement in queue.js --- queue.js | 1 + 1 file changed, 1 insertion(+) diff --git a/queue.js b/queue.js index 53c03c1..b4be908 100644 --- a/queue.js +++ b/queue.js @@ -4,6 +4,7 @@ */ var Feed = require("./feed.js").Feed, + redis = require("redis"), uuid = require("node-uuid"); /** From d6ddb2c37a573c775b4e224fb8b2f27c98894777 Mon Sep 17 00:00:00 2001 From: Mani Fazeli Date: Fri, 22 Jun 2012 16:14:01 -0400 Subject: [PATCH 2/5] Added Redis authentication with a constructor password argument --- README.md | 4 ++-- job.js | 5 +++++ queue.js | 5 +++++ thoonk.js | 24 +++++++++++++++++++----- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c899ca6..4abc5da 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,11 @@ configured. Then run: ## Initializing ## var Thoonk = require("thoonk").Thoonk; - var thoonk = new Thoonk(host, port, db) + var thoonk = new Thoonk(host, port, db, password) Or, you can use: - var thoonk = require("thoonk").createClient(host, port, db); + var thoonk = require("thoonk").createClient(host, port, db, password); ## Creating a Feed ## diff --git a/job.js b/job.js index ed2d7fd..2d6650f 100644 --- a/job.js +++ b/job.js @@ -74,6 +74,11 @@ var Feed = require("./feed.js").Feed, function Job(thoonk, name, config) { Feed.call(this, thoonk, name, config, 'job'); this.bredis = redis.createClient(this.thoonk.port, this.thoonk.host); + if (this.thoonk.password) { + this.bredis.auth(this.thoonk.password, function (err) { + if (err) { throw err; } + }); + } this.bredis.select(this.thoonk.db); this.publish = this.thoonk.lock.require(jobPublish, this); this.put = this.thoonk.lock.require(jobPublish, this); diff --git a/queue.js b/queue.js index b4be908..a9c365e 100644 --- a/queue.js +++ b/queue.js @@ -33,6 +33,11 @@ var Feed = require("./feed.js").Feed, function Queue(thoonk, name, config) { Feed.call(this, thoonk, name, config, 'queue'); this.bredis = redis.createClient(this.thoonk.port, this.thoonk.host); + if (this.thoonk.password) { + this.bredis.auth(this.thoonk.password, function (err) { + if (err) { throw err; } + }); + } this.bredis.select(this.thoonk.db); this.publish = this.thoonk.lock.require(queuePublish, this); this.put = this.thoonk.lock.require(queuePublish, this); diff --git a/thoonk.js b/thoonk.js index f5c59ba..7589982 100644 --- a/thoonk.js +++ b/thoonk.js @@ -20,19 +20,33 @@ var Feed = exports.Feed = require("./feed.js").Feed, * * @param host * @param port + * @param db + * @param password */ -var Thoonk = exports.Thoonk = function Thoonk(host, port, db) { +var Thoonk = exports.Thoonk = function Thoonk(host, port, db, password) { host || (host = "127.0.0.1"); port || (port = 6379); db || (db = 0); + password || (password = ""); this.host = host; this.port = port; this.db = db; + this.password = password; EventEmitter.call(this); this.lredis = redis.createClient(port, host); + if (password) { + this.lredis.auth(password, function (err) { + if (err) { throw err; } + }); + } this.lredis.select(db); this.lredis.subscribe("newfeed", "delfeed", "conffeed"); this.mredis = redis.createClient(port, host); + if (password) { + this.mredis.auth(password, function (err) { + if (err) { throw err; } + }); + } this.mredis.select(db); this.lock = new padlock.Padlock(); @@ -416,10 +430,10 @@ Thoonk.prototype.getFeedNames = function(callback, error_callback) { * Shortcut function to make creating a Thoonk instance * easier, as so: * - * var pubsub = require("thoonk").createClient(host, port, db); + * var pubsub = require("thoonk").createClient(host, port, db, password); */ -exports.createClient = function(host, port, db) { - return new Thoonk(host, port, db); +exports.createClient = function(host, port, db, password) { + return new Thoonk(host, port, db, password); } -exports.VERSION = '0.5.1'; +exports.VERSION = '0.5.3'; From 11b39a77e5476b6dbc297c02f85edae639227bf9 Mon Sep 17 00:00:00 2001 From: Mani Fazeli Date: Mon, 25 Jun 2012 09:54:03 -0400 Subject: [PATCH 3/5] Modified tests to use password as set in config file --- testconfig.json | 2 +- tests/test_feeds.js | 2 +- tests/test_jobs.js | 2 +- tests/test_lists.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testconfig.json b/testconfig.json index 9b7a833..ec80410 100644 --- a/testconfig.json +++ b/testconfig.json @@ -1 +1 @@ -{"enabled": false, "host": "localhost", "port": 6379, "db": 10 } +{"enabled": true, "host": "localhost", "port": 6379, "db": 0, "password": ""} diff --git a/tests/test_feeds.js b/tests/test_feeds.js index c74dd6c..df81cbe 100644 --- a/tests/test_feeds.js +++ b/tests/test_feeds.js @@ -16,7 +16,7 @@ var tests = new TestObject([ "hasId4:true", "hasId1:false", ], function(config) { - var thoonk = new Thoonk(config.host, config.port, config.db); + var thoonk = new Thoonk(config.host, config.port, config.db, config.password); tests.on("done", function() { thoonk.quit(); }); diff --git a/tests/test_jobs.js b/tests/test_jobs.js index c14e871..c9de26f 100644 --- a/tests/test_jobs.js +++ b/tests/test_jobs.js @@ -6,7 +6,7 @@ var tests = new TestObject([ "publish: item2", "publish: item3", ], function(config) { - var thoonk = new Thoonk(config.host, config.port, config.db); + var thoonk = new Thoonk(config.host, config.port, config.db, config.password); tests.on("done", function() { thoonk.quit(); }); diff --git a/tests/test_lists.js b/tests/test_lists.js index 1eaf7b2..1cf2b3d 100644 --- a/tests/test_lists.js +++ b/tests/test_lists.js @@ -19,7 +19,7 @@ var tests = new TestObject([ "position:6 :end", 'edit:6: neehawedit', ], function(config) { - var thoonk = new Thoonk(config.host, config.port, config.db); + var thoonk = new Thoonk(config.host, config.port, config.db, config.password); tests.on("done", function() { thoonk.quit(); }); From 07e8672ef7003b9e8718b5c36d7edc92d294d19e Mon Sep 17 00:00:00 2001 From: Mani Fazeli Date: Mon, 5 Nov 2012 13:09:24 -0500 Subject: [PATCH 4/5] Locking in the version of thoonk's depedencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d92af4b..77be85b 100644 --- a/package.json +++ b/package.json @@ -9,5 +9,5 @@ "files": ["feed.js", "job.js", "queue.js", "sorted_feed.js", "testall.js", "thoonk.js", "tests", "examples", "LICENSE", "README.md", "contract.txt", "testconfig.json"], "main": "./thoonk.js", "repository": {"type": "git", "url": "http://github.com/fritzy/thoonk.js.git"}, - "dependencies": {"node-uuid": ">=1.1.0", "redis": ">=0.5.5", "padlock": ">=1.0.0"} + "dependencies": {"node-uuid": "1.4.0", "redis": "0.6.7", "padlock": "1.1.2"} } From 4bd0123a749122281b29284cb94c66c2d3fd6e8a Mon Sep 17 00:00:00 2001 From: Mani Fazeli Date: Fri, 9 Nov 2012 09:56:32 -0500 Subject: [PATCH 5/5] Fixing incorrect padlock version (1.1.2 -> 1.0.2) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77be85b..7dca75f 100644 --- a/package.json +++ b/package.json @@ -9,5 +9,5 @@ "files": ["feed.js", "job.js", "queue.js", "sorted_feed.js", "testall.js", "thoonk.js", "tests", "examples", "LICENSE", "README.md", "contract.txt", "testconfig.json"], "main": "./thoonk.js", "repository": {"type": "git", "url": "http://github.com/fritzy/thoonk.js.git"}, - "dependencies": {"node-uuid": "1.4.0", "redis": "0.6.7", "padlock": "1.1.2"} + "dependencies": {"node-uuid": "1.4.0", "redis": "0.6.7", "padlock": "1.0.2"} }