CartoDB-SQL-API/batch/index.js

28 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
2016-01-23 02:31:25 +08:00
var redis = require('redis');
var JobRunner = require('./job_runner');
var JobCanceller = require('./job_canceller');
var JobQueuePool = require('./job_queue_pool');
var JobSubscriber = require('./job_subscriber');
var UserDatabaseMetadataService = require('./user_database_metadata_service');
var JobPublisher = require('./job_publisher');
var JobQueue = require('./job_queue');
var UserIndexer = require('./user_indexer');
var JobBackend = require('./job_backend');
var Batch = require('./batch');
module.exports = function batchFactory (metadataBackend) {
2016-01-23 02:31:25 +08:00
var jobSubscriber = new JobSubscriber(redis);
var jobQueuePool = new JobQueuePool(metadataBackend);
2016-01-23 02:31:25 +08:00
var jobPublisher = new JobPublisher(redis);
var jobQueue = new JobQueue(metadataBackend);
var userIndexer = new UserIndexer(metadataBackend);
var jobBackend = new JobBackend(metadataBackend, jobQueue, jobPublisher, userIndexer);
var userDatabaseMetadataService = new UserDatabaseMetadataService(metadataBackend);
var jobRunner = new JobRunner(jobBackend, userDatabaseMetadataService);
var jobCanceller = new JobCanceller(metadataBackend, userDatabaseMetadataService, jobBackend);
return new Batch(jobSubscriber, jobQueuePool, jobRunner, jobCanceller);
};