Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting of Redis connection parameters #35

Merged
merged 6 commits into from Jul 25, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion Readme.md
Expand Up @@ -196,6 +196,25 @@ jobs.process('slideshow pdf', 5, function(job, done){
});
```

## Redis Connection Settings

By default, Kue will connect to Redis using the client default settings (port defaults to `6389`, host defaults to `127.0.0.1`). Redis client connection settings can be set by overriding the `kue.redis.createConnection` function.

For example, to create a Redis client that connects to `192.168.1.2` on port `1234` that requires authentication, use the following:

```javascript
var kue = require('kue')
, redis = require('redis');

kue.redis.createClient = function() {
var client = redis.createClient(1234, '192.168.1.2');
client.auth('YOUR_PASSWORD');
return client;
}
```

Redis connection settings must be set before calling `kue.createQueue()` or accessing `kue.app`.

## User-Interface

The UI is a small [Express](http://github.com/visionmedia/express) application, to fire it up simply run the following, altering the port etc as desired.
Expand Down Expand Up @@ -348,4 +367,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 16 additions & 2 deletions lib/kue.js
Expand Up @@ -13,7 +13,7 @@ var EventEmitter = require('events').EventEmitter
, Worker = require('./queue/worker')
, events = require('./queue/events')
, Job = require('./queue/job')
, redis = require('redis');
, redis = require('./redis');

/**
* Expose `Queue`.
Expand All @@ -33,11 +33,25 @@ exports.version = '0.1.0';

exports.Job = Job;

/**
* Server instance (that is lazily required)
*/

var app;

/**
* Expose the server.
*/

exports.app = require('./http');
Object.defineProperty(exports, 'app', {
get: function() { return app || (app = require('./http')); }
});

/**
* Expose the RedisClient factory.
*/

exports.redis = redis;

/**
* Create a new `Queue`.
Expand Down
5 changes: 3 additions & 2 deletions lib/queue/pool.js
Expand Up @@ -9,7 +9,7 @@
* Module dependencies.
*/

var redis = require('redis');
var redis = require('../redis');

/**
* Max connections in the pool.
Expand Down Expand Up @@ -49,4 +49,5 @@ exports.alloc = function(){

exports.pubsubClient = function(){
return exports._pubsub || (exports._pubsub = redis.createClient());
};
};

2 changes: 1 addition & 1 deletion lib/queue/worker.js
Expand Up @@ -10,7 +10,7 @@
*/

var EventEmitter = require('events').EventEmitter
, redis = require('redis')
, redis = require('../redis')
, Job = require('./job')
, events = require('./events');

Expand Down
24 changes: 24 additions & 0 deletions lib/redis.js
@@ -0,0 +1,24 @@

/*!
* kue - RedisClient factory
* Copyright (c) 2011 LearnBoost <tj@learnboost.com>
* MIT Licensed
* Author: bitprobe@gmail.com
*/

/**
* Module dependencies.
*/
var redis = require('redis');

/**
* Create a RedisClient
*
* @return {RedisClient}
* @api private
*/

exports.createClient = function() {
return redis.createClient();
};