Skip to content

Commit

Permalink
Fix typo and different things
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin01 committed Nov 17, 2014
1 parent 5d6ace7 commit 16ec486
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/handlers/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var util = require('../util.js');
* This handler downloads data for the specified access_token and starts uploading them onto AnyFetch.
*
*/
module.exports.postGenerator = function postGenerator(yagsClient, queue, config) {
module.exports.postGenerator = function postGenerator(yags, queue, config) {
return function updatePost(req, res, next) {
if(!req.params.documents_per_update && !req.params.identifier) {
return next(new restify.MissingParameterError("Missing documents_per_update parameter."));
Expand Down Expand Up @@ -51,7 +51,8 @@ module.exports.postGenerator = function postGenerator(yagsClient, queue, config)
req.token.save(rarity.slice(1, cb));
},
function createUpdateJob(cb) {
var userQueue = yagsClient.createQueue(req.token.accountName, {concurrency: config.concurrency || 1});
// This queue manage a unique user and contain a update task which will put different tasks on it
var userQueue = yags.createQueue(req.token.accountName, {concurrency: config.concurrency || 1});

userQueue.createJob({
type: 'update',
Expand Down
1 change: 1 addition & 0 deletions lib/queues/user-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var Anyfetch = require('anyfetch');

var Token = require('../models/token.js');

// This worker is use to manage specific tasks to a user (update / normal task)
module.exports = function userQueueGenerator(server, config, workers, updateAccount) {
function executeUpdateJob(token, job, cb) {
async.waterfall([
Expand Down
3 changes: 2 additions & 1 deletion lib/queues/users-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var Token = require('../models/token.js');

var userQueue = require('./user-queue.js');

// This worker is use to manage a list of queues, it contain one task per user which call /update
module.exports = function usersQueueGenerator(server, config, workers, updateAccount) {
return function usersQueue(job, finalCb) {
async.waterfall([
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = function usersQueueGenerator(server, config, workers, updateAcc
});

queue.on('job.timeout', function(job) {
console.log("Job " + job.id + " timeout");
console.log("Job " + job.id + " timeouted");
});

queue.once('empty', function() {
Expand Down
6 changes: 3 additions & 3 deletions test/handlers/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("POST /update endpoint", function() {
updateServer(server);

server.usersQueue.once('empty', function() {
counter.should.be.eql(tasks.length);
counter.should.eql(tasks.length);
done();
});
});
Expand Down Expand Up @@ -149,7 +149,7 @@ describe("POST /update endpoint", function() {
updateServer(server, 'b');

server.usersQueue.once('empty', function() {
counter.should.be.eql(1);
counter.should.eql(1);
done();
});
});
Expand All @@ -174,7 +174,7 @@ describe("POST /update endpoint", function() {
updateServer(server);

server.usersQueue.once('empty', function() {
counter.should.be.eql(1);
counter.should.eql(1);
done();
});
});
Expand Down

0 comments on commit 16ec486

Please sign in to comment.