c308551d05
Split job acceptance test
22 lines
678 B
JavaScript
22 lines
678 B
JavaScript
'use strict';
|
|
|
|
function JobQueue(metadataBackend) {
|
|
this.metadataBackend = metadataBackend;
|
|
this.db = 5;
|
|
this.redisPrefix = 'batch:queues:';
|
|
}
|
|
|
|
JobQueue.prototype.enqueue = function (job_id, host, callback) {
|
|
this.metadataBackend.redisCmd(this.db, 'LPUSH', [ this.redisPrefix + host, job_id ], callback);
|
|
};
|
|
|
|
JobQueue.prototype.dequeue = function (host, callback) {
|
|
this.metadataBackend.redisCmd(this.db, 'RPOP', [ this.redisPrefix + host ], callback);
|
|
};
|
|
|
|
JobQueue.prototype.enqueueFirst = function (job_id, host, callback) {
|
|
this.metadataBackend.redisCmd(this.db, 'RPUSH', [ this.redisPrefix + host, job_id ], callback);
|
|
};
|
|
|
|
module.exports = JobQueue;
|