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? }); 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';