Skip to content

Commit 6514bf8

Browse files
committed
Merge pull request #30 from AnyFetch/priority
Priority on /hydrate
2 parents c708392 + 5a3d30e commit 6514bf8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/handlers/hydrater.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ module.exports = function(req, res, server, logger, next) {
4242

4343
// Push it to the queue
4444
if(req.params.long_poll) {
45-
server.queue.unshift(task);
45+
server.queue.push(task, -100);
4646
}
4747
else {
48-
server.queue.push(task);
48+
server.queue.push(task, (req.params.priority) ? -parseInt(req.params.priority) : 0);
4949
}
5050
logger("Queuing: " + ((task.file_path) ? task.file_path : task.document.id));
5151
};

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports.createServer = function(config) {
3333
server.use(restify.queryParser());
3434
server.use(restify.bodyParser());
3535

36-
server.queue = async.queue(hydraterHelper, config.concurrency || 1);
36+
server.queue = async.priorityQueue(hydraterHelper, config.concurrency || 1);
3737

3838
// Load routes
3939
server.post('/hydrate', function(req, res, next) {

0 commit comments

Comments
 (0)