From 87e2eac9b258cbd8cf785580e8179893182c3938 Mon Sep 17 00:00:00 2001 From: Jeremiah Johnson Date: Thu, 29 Dec 2011 02:24:30 -0700 Subject: [PATCH 1/2] initial add of password parameter --- thoonk.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/thoonk.js b/thoonk.js index 887dc47..e85bb90 100644 --- a/thoonk.js +++ b/thoonk.js @@ -21,7 +21,7 @@ var Feed = exports.Feed = require("./feed.js").Feed, * @param host * @param port */ -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); @@ -31,9 +31,15 @@ var Thoonk = exports.Thoonk = function Thoonk(host, port, db) { EventEmitter.call(this); this.setMaxListeners(100000); this.lredis = redis.createClient(port, host); + if (typeof password != 'undefined') { + this.lredis.auth(password); + } this.lredis.select(db); this.lredis.subscribe("newfeed", "delfeed", "conffeed"); this.mredis = redis.createClient(port, host); + if (typeof password != 'undefined') { + this.mredis.auth(password); + } this.mredis.select(db); this.lock = new padlock.Padlock(); @@ -471,10 +477,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'; From 8c06b479a698850cde875bf986e79c8451520011 Mon Sep 17 00:00:00 2001 From: Jeremiah Johnson Date: Fri, 30 Dec 2011 00:01:37 -0700 Subject: [PATCH 2/2] corrected the parameter list in the callback for feed.publish and feed.retract --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bfc99b0..ff2d157 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ The pattern uses asterisks (*) for matching. Publishing to a feed adds an item to the end of the feed, sorted by publish time. - feed.publish('item contents', 'optional id', function(item, id) { + feed.publish('item contents', 'optional id', function(err, item, id) { //done publishing! }); @@ -174,7 +174,7 @@ structure by only working the IDs and not with the item contents. Removing an item is done through retraction, which simply requires the ID of the item to remove. - feed.retract('item id', function(id, error) { + feed.retract('item id', function(err, id) { //success? });