2015-12-16 22:57:58 +08:00
|
|
|
'use strict';
|
|
|
|
|
2015-12-29 17:19:10 +08:00
|
|
|
var JobQueue = require('./job_queue');
|
|
|
|
|
|
|
|
function JobQueuePool(metadataBackend) {
|
|
|
|
this.metadataBackend = metadataBackend;
|
2015-12-16 22:57:58 +08:00
|
|
|
this.queues = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
JobQueuePool.prototype.get = function (host) {
|
|
|
|
return this.queues[host];
|
|
|
|
};
|
|
|
|
|
|
|
|
JobQueuePool.prototype.list = function () {
|
|
|
|
return Object.keys(this.queues);
|
|
|
|
};
|
|
|
|
|
2015-12-29 17:19:10 +08:00
|
|
|
JobQueuePool.prototype.add = function (host) {
|
|
|
|
this.queues[host] = new JobQueue(this.metadataBackend);
|
|
|
|
return this.get(host);
|
2015-12-16 22:57:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
JobQueuePool.prototype.remove = function (host) {
|
|
|
|
delete this.queues[host];
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = JobQueuePool;
|