CartoDB-SQL-API/batch/index.js

35 lines
1.6 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 QueryRunner = require('./query_runner');
var JobCanceller = require('./job_canceller');
var JobQueuePool = require('./job_queue_pool');
var JobSubscriber = require('./job_subscriber');
var QueueSeeker = require('./queue_seeker');
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');
2016-05-14 00:50:55 +08:00
var JobService = require('./job_service');
var Batch = require('./batch');
module.exports = function batchFactory (metadataBackend) {
var queueSeeker = new QueueSeeker(metadataBackend);
var jobSubscriber = new JobSubscriber(redis, queueSeeker);
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);
2016-05-14 00:50:55 +08:00
// TODO: down userDatabaseMetadataService
var queryRunner = new QueryRunner();
2016-05-16 07:22:47 +08:00
var jobCanceller = new JobCanceller(userDatabaseMetadataService);
2016-05-14 00:50:55 +08:00
var jobService = new JobService(jobBackend, jobCanceller);
var jobRunner = new JobRunner(jobService, jobQueue, queryRunner, userDatabaseMetadataService);
2016-05-14 00:50:55 +08:00
return new Batch(jobSubscriber, jobQueuePool, jobRunner, jobService);
};