Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #659 from gitig/master
Browse files Browse the repository at this point in the history
希望可以给task自定义timeout
  • Loading branch information
py8765 committed Dec 4, 2014
2 parents 3a1cdfd + 66e68fa commit 87f1713
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/common/manager/taskManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ manager.timeout = 3000;
* @param {String} key task key
* @param {Function} fn task callback
* @param {Function} ontimeout task timeout callback
* @param {Number} timeout timeout for task
*/
manager.addTask = function(key, fn, ontimeout) {
manager.addTask = function(key, fn, ontimeout, timeout) {
var queue = queues[key];
if(!queue) {
queue = sequeue.createQueue(manager.timeout);
queues[key] = queue;
}

return queue.push(fn, ontimeout);
return queue.push(fn, ontimeout, timeout);
};

/**
Expand Down
9 changes: 5 additions & 4 deletions lib/filters/handler/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
var logger = require('pomelo-logger').getLogger('pomelo', __filename);
var taskManager = require('../../common/manager/taskManager');

module.exports = function() {
return new Filter();
module.exports = function(timeout) {
return new Filter(timeout);
};

var Filter = function() {
var Filter = function(timeout) {
this.timeout = timeout
};

/**
Expand All @@ -20,7 +21,7 @@ Filter.prototype.before = function(msg, session, next) {
next();
}, function() {
logger.error('[serial filter] msg timeout, msg:' + JSON.stringify(msg));
});
}, this.timeout);
};

/**
Expand Down

0 comments on commit 87f1713

Please sign in to comment.