2015-12-29 17:19:10 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function JobQueue(metadataBackend) {
|
|
|
|
this.metadataBackend = metadataBackend;
|
|
|
|
this.db = 5;
|
2015-12-31 03:16:18 +08:00
|
|
|
this.redisPrefix = 'batch:queues:';
|
2015-12-29 17:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
JobQueue.prototype.enqueue = function (job_id, host, callback) {
|
2015-12-31 03:16:18 +08:00
|
|
|
this.metadataBackend.redisCmd(this.db, 'LPUSH', [ this.redisPrefix + host, job_id ], callback);
|
2015-12-29 17:19:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
JobQueue.prototype.dequeue = function (host, callback) {
|
2015-12-31 03:16:18 +08:00
|
|
|
this.metadataBackend.redisCmd(this.db, 'RPOP', [ this.redisPrefix + host ], callback);
|
2015-12-29 17:19:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = JobQueue;
|