rsmq-worker
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -68,2 +68,4 @@ (function() { | ||
this._getRsmq = bind(this._getRsmq, this); | ||
this._onReConnect = bind(this._onReConnect, this); | ||
this._onDisconnect = bind(this._onDisconnect, this); | ||
this._initRSMQ = bind(this._initRSMQ, this); | ||
@@ -110,3 +112,7 @@ this.changeInterval = bind(this.changeInterval, this); | ||
RSMQWorker.prototype.start = function() { | ||
var ref; | ||
if (this.ready) { | ||
if (((ref = this.queue.listeners('disconnect')) != null ? ref.indexOf(this._onDisconnect) : void 0) < 0) { | ||
this.queue.on("disconnect", this._onDisconnect); | ||
} | ||
this.stopped = false; | ||
@@ -136,2 +142,3 @@ this.interval(); | ||
this.stopped = true; | ||
this.queue.removeListener("disconnect", this._onDisconnect); | ||
if (this.timeout != null) { | ||
@@ -278,25 +285,2 @@ clearTimeout(this.timeout); | ||
this.reconnectActive = false; | ||
this.queue.on("disconnect", (function(_this) { | ||
return function(err) { | ||
var _interval; | ||
_this.warning("redis connection lost"); | ||
_interval = _this.timeout != null; | ||
if (!_this.reconnectActive) { | ||
_this.reconnectActive = true; | ||
if (_interval) { | ||
_this.stop(); | ||
} | ||
_this.queue.once("connect", function() { | ||
_this.waitCount = 0; | ||
_this.reconnectActive = false; | ||
_this.queue = new _this._getRsmq(true); | ||
_this._runOfflineMessages(); | ||
if (_interval) { | ||
_this.interval(); | ||
} | ||
_this.warning("redis connection reconnected"); | ||
}); | ||
} | ||
}; | ||
})(this)); | ||
if (this.queue.connected) { | ||
@@ -311,2 +295,50 @@ this._initQueue(); | ||
/* | ||
## _onDisconnect | ||
`RSMQWorker._onDisconnect()` | ||
internal handler on disconnect | ||
@param { Error } the redis connection error | ||
@api private | ||
*/ | ||
RSMQWorker.prototype._onDisconnect = function(err) { | ||
var _interval; | ||
this.warning("redis connection lost", err); | ||
_interval = this.timeout != null; | ||
if (!this.reconnectActive) { | ||
this.reconnectActive = true; | ||
if (_interval) { | ||
this.stop(); | ||
} | ||
this.queue.once("connect", this._onReConnect); | ||
} | ||
}; | ||
/* | ||
## _onReConnect | ||
`RSMQWorker._onReConnect()` | ||
internal handler on a reconnect | ||
@api private | ||
*/ | ||
RSMQWorker.prototype._onReConnect = function() { | ||
this.waitCount = 0; | ||
this.reconnectActive = false; | ||
this.queue = this._getRsmq(true); | ||
this._runOfflineMessages(); | ||
if (_interval) { | ||
this.interval(); | ||
} | ||
this.warning("redis connection reconnected"); | ||
}; | ||
/* | ||
## _getRsmq | ||
@@ -313,0 +345,0 @@ |
{ | ||
"name": "rsmq-worker", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "RSMQ helper to simply implement a worker around the message queue", | ||
@@ -32,3 +32,3 @@ "keywords": [], | ||
"devDependencies": { | ||
"should": "8.x", | ||
"should": "9.x", | ||
"grunt": "1.x", | ||
@@ -35,0 +35,0 @@ "grunt-contrib-watch": "1.x", |
![RSMQ-Worker](https://trello-attachments.s3.amazonaws.com/5481963992d9ba3848568a1b/600x194/61b3b6117eeb0881c919c6996adb2620/rsmq_worker_small.png) | ||
[![Build Status](https://secure.travis-ci.org/mpneuried/rsmq-worker.png?branch=master)](http://travis-ci.org/mpneuried/rsmq-worker) | ||
[![Build Status](https://david-dm.org/mpneuried/rsmq-worker.png)](https://david-dm.org/mpneuried/rsmq-worker) | ||
[![Windows Tests](https://img.shields.io/appveyor/ci/mpneuried/rsmq-worker.svg?label=Windows%20Test)]() | ||
[![Dependencies Status](https://david-dm.org/mpneuried/rsmq-worker.png)](https://david-dm.org/mpneuried/rsmq-worker) | ||
[![NPM version](https://badge.fury.io/js/rsmq-worker.png)](http://badge.fury.io/js/rsmq-worker) | ||
@@ -32,4 +33,6 @@ | ||
worker.on( "message", function( msg, next ){ | ||
worker.on( "message", function( msg, next, id ){ | ||
// process your message | ||
console.log("Message id : " + id); | ||
console.log(msg); | ||
next() | ||
@@ -310,2 +313,3 @@ }); | ||
|:--:|:--:|:--| | ||
|0.4.3|2016-06-20|Optimized event listeners [Issue#15](https://github.com/mpneuried/rsmq-worker/issues/15). Thanks to [Kevin Turner](https://github.com/kpturner )| | ||
|0.4.2|2016-05-06|Added the `.quit()` function [Issue#11](https://github.com/mpneuried/rsmq-worker/issues/11). Thanks to [Sam Fung](https://github.com/5amfung )| | ||
@@ -312,0 +316,0 @@ |0.4.1|2016-04-05|Fixed missing isNumber function| |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41316
11
732
362