Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Always have a child redis client for workers

  • Loading branch information...
commit 1757066f041fe298b653acdb19bca31dcdd23bb4 1 parent 4abd86a
@tim-smart tim-smart authored
Showing with 11 additions and 17 deletions.
  1. +11 −17 index.js
View
28 index.js
@@ -121,6 +121,17 @@ var Worker = function (options) {
// TODO: Rename?
this.continual = false;
+ // Client for use with child jobs.
+ this._child_client = redis.createClient(this.port, this.host);
+
+ if (this.auth) {
+ this._child_client.auth(this.auth);
+ }
+
+ this._child_client.on('error', function (error) {
+ self.emit('error', error);
+ });
+
/**
* Callback for blpop responses.
*
@@ -183,23 +194,6 @@ Worker.prototype.start = function () {
self.emit('error', error);
});
- if (this.continual) {
- if (!this._child_client) {
- // Client for use with child jobs.
- this._child_client = redis.createClient(this.port, this.host);
-
- if (this.auth) {
- this._child_client.auth(this.auth);
- }
-
- this._child_client.on('error', function (error) {
- self.emit('error', error);
- });
- }
- } else {
- this._child_client = this.client;
- }
-
this.next();
};
Please sign in to comment.
Something went wrong with that request. Please try again.