Skip to content

Commit de13431

Browse files
committed
Merge pull request #31 from AnyFetch/forward-priority
Forward priority to child process
2 parents f1b8e88 + 3e092fb commit de13431

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/handlers/hydrater.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ module.exports = function(req, res, server, logger, next) {
4040
task.document.metadata = task.document ? task.document.metadata || {} : {};
4141
task.document.data = task.document ? task.document.data || {} : {};
4242

43-
// Push it to the queue
43+
4444
if(req.params.long_poll) {
45-
server.queue.push(task, -100);
45+
task.priority = -100;
4646
}
4747
else {
48-
server.queue.push(task, (req.params.priority) ? -parseInt(req.params.priority) : 0);
48+
task.priority = (req.params.priority) ? -parseInt(req.params.priority) : 0;
4949
}
50+
51+
// Push it to the queue
52+
server.queue.push(task, task.priority);
53+
5054
logger("Queuing: " + ((task.file_path) ? task.file_path : task.document.id));
5155
};

lib/helpers/child-process.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ process.on('message', function(task) {
5454
}
5555
},
5656
function startHydration(cb) {
57+
cb.priority = task.priority;
5758
cb.urlCallback = task.options.urlCallback;
5859
cb.apiUrl = task.options.apiUrl;
5960
hydrate(path, task.document, task.changes, cb);

lib/helpers/hydrater.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ module.exports = function(hydraterFunction, logger, errLogger) {
101101

102102
child.send({
103103
functionPath: hydraterFunction,
104+
priority: task.priority,
104105
file_path: task.file_path,
105106
document: task.document,
106107
changes: lib.defaultChanges(),

0 commit comments

Comments
 (0)