Skip to content

Commit

Permalink
Redis is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Dec 7, 2009
1 parent 7b0d57f commit 82fdbac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ The end goal of the project is to provide an abstraction layer of the protocol u
Requirements
------------

* [Node.js](http://nodejs.org/) (tested with v0.1.20-3-g5b1a535)
* [Redis](http://code.google.com/p/redis/) used for logging. [redis-node-client](http://github.com/fictorial/redis-node-client) is included.

* [Node.js](http://nodejs.org/) (tested with v0.1.21)

Optional:

* [Redis](http://code.google.com/p/redis/) used for logging. [redis-node-client](http://github.com/fictorial/redis-node-client) is included. See `log.js` for the benefits of Redis as a logging mechanism.

How to use
----------
Expand Down
5 changes: 2 additions & 3 deletions lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var Client = exports.Client = function (port, host) {

// Callback a function after we've ensured we're connected to Redis.

Client.prototype.connect = function (callback_on_connect) {
Client.prototype.connect = function (callback_on_connect, callback_on_error) {
var self = this;
if (this.conn && this.conn.readyState === "open") {
if (typeof(callback_on_connect) === "function")
Expand All @@ -59,8 +59,7 @@ Client.prototype.connect = function (callback_on_connect) {
self.handle_replies();
});
this.conn.addListener("close", function (encountered_error) {
if (encountered_error)
throw new Error("redis server up?");
if (encountered_error && callback_on_error) callback_on_error();
});
this.conn.connect(this.port, this.host);
}
Expand Down
6 changes: 4 additions & 2 deletions log.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ author: [Guillermo Rauch](http://devthought.com)

var sys = require('sys'),
redis = require('./lib/redis'),
ready = false,
ready = null,
busy = false,
client = new redis.Client(),
stack = [],
Expand Down Expand Up @@ -63,4 +63,6 @@ this.store = function(message, type){
};

// connect to redis
client.connect(onConnect);
client.connect(onConnect, function(){
ready = false;
});

0 comments on commit 82fdbac

Please sign in to comment.