Skip to content

Commit e8e46b9

Browse files
committedNov 11, 2016
Updated Async library to get unsaturated event handled.
Fixed minor bugs. Call new poll only after the task gets queued (only this way we can make sure that the queue is not saturated already).
1 parent 74a6ea9 commit e8e46b9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed
 

‎lib/poller.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ var Poller = exports.Poller = function(config, swfClient) {
2727
this.logger = config.logger || console;
2828
delete config.logger
2929
this.taskLimitation = config.taskLimitation || Number.MAX_SAFE_INTEGER;
30+
delete config.taskLimitation
3031
this.taskQueue = async.queue(function(queueFunc, callback){
31-
queueFunc(callback);
32+
if (!self.pause_poller) {
33+
self.poll();
34+
}
35+
queueFunc(callback);
3236
}, this.taskLimitation);
33-
this.taskQueue.drain = function(){
34-
if (this.pause_poller) {
37+
this.taskQueue.unsaturated = function(){
38+
if (self.pause_poller) {
3539
self.resume();
3640
}
3741
};
3842
this.taskQueue.saturated = function(){
39-
if (!this.pause_poller) {
43+
if (!self.pause_poller) {
4044
self.pause();
4145
}
4246
};
@@ -117,7 +121,7 @@ Poller.prototype.stop = function () {
117121
Poller.prototype.poll = function () {
118122

119123
if (this.stop_poller || this.pause_poller) {
120-
this.logger.info('Poller stopped, shutting down...');
124+
this.logger.info('Poller stopped or paused');
121125
return;
122126
}
123127

@@ -162,7 +166,6 @@ Poller.prototype.poll = function () {
162166
return;
163167
}
164168
_this._onNewTask(result);
165-
_this.poll();
166169
});
167170

168171
};

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"url": "http://github.com/neyric/aws-swf.git"
2222
},
2323
"dependencies": {
24-
"async": "^1.5.0",
24+
"async": "^2.1.2",
2525
"aws-sdk": "^2.2.22",
2626
"lodash": "^3.10.1"
2727
},

0 commit comments

Comments
 (0)