CartoDB-SQL-API/batch/job_queue_pool.js

28 lines
584 B
JavaScript
Raw Normal View History

'use strict';
var JobQueue = require('./job_queue');
function JobQueuePool(metadataBackend) {
this.metadataBackend = metadataBackend;
this.queues = {};
}
JobQueuePool.prototype.get = function (host) {
return this.queues[host];
};
JobQueuePool.prototype.list = function () {
return Object.keys(this.queues);
};
JobQueuePool.prototype.add = function (host) {
this.queues[host] = new JobQueue(this.metadataBackend);
return this.get(host);
};
JobQueuePool.prototype.remove = function (host) {
delete this.queues[host];
};
module.exports = JobQueuePool;