2016-01-08 18:32:01 +08:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-23 02:31:25 +08:00
|
|
|
var redis = require('redis');
|
2016-01-08 18:32:01 +08:00
|
|
|
var JobRunner = require('./job_runner');
|
2016-03-31 18:39:03 +08:00
|
|
|
var QueryRunner = require('./query_runner');
|
2016-01-13 23:25:25 +08:00
|
|
|
var JobCanceller = require('./job_canceller');
|
2016-01-08 18:32:01 +08:00
|
|
|
var JobQueuePool = require('./job_queue_pool');
|
|
|
|
var JobSubscriber = require('./job_subscriber');
|
2016-04-04 22:05:33 +08:00
|
|
|
var QueueSeeker = require('./queue_seeker');
|
2016-01-08 18:32:01 +08:00
|
|
|
var UserDatabaseMetadataService = require('./user_database_metadata_service');
|
|
|
|
var JobPublisher = require('./job_publisher');
|
|
|
|
var JobQueue = require('./job_queue');
|
|
|
|
var UserIndexer = require('./user_indexer');
|
2016-01-08 22:47:59 +08:00
|
|
|
var JobBackend = require('./job_backend');
|
2016-05-14 00:50:55 +08:00
|
|
|
var JobService = require('./job_service');
|
2016-01-08 18:32:01 +08:00
|
|
|
var Batch = require('./batch');
|
|
|
|
|
|
|
|
module.exports = function batchFactory (metadataBackend) {
|
2016-04-04 22:05:33 +08:00
|
|
|
var queueSeeker = new QueueSeeker(metadataBackend);
|
|
|
|
var jobSubscriber = new JobSubscriber(redis, queueSeeker);
|
2016-01-08 18:32:01 +08:00
|
|
|
var jobQueuePool = new JobQueuePool(metadataBackend);
|
2016-01-23 02:31:25 +08:00
|
|
|
var jobPublisher = new JobPublisher(redis);
|
2016-01-08 18:32:01 +08:00
|
|
|
var jobQueue = new JobQueue(metadataBackend);
|
|
|
|
var userIndexer = new UserIndexer(metadataBackend);
|
2016-01-08 22:47:59 +08:00
|
|
|
var jobBackend = new JobBackend(metadataBackend, jobQueue, jobPublisher, userIndexer);
|
|
|
|
var userDatabaseMetadataService = new UserDatabaseMetadataService(metadataBackend);
|
2016-05-14 00:50:55 +08:00
|
|
|
// TODO: down userDatabaseMetadataService
|
2016-03-31 18:39:03 +08:00
|
|
|
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-01-08 18:32:01 +08:00
|
|
|
|
2016-05-14 00:50:55 +08:00
|
|
|
return new Batch(jobSubscriber, jobQueuePool, jobRunner, jobService);
|
2016-01-08 18:32:01 +08:00
|
|
|
};
|