2016-01-08 18:32:01 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-04 00:24:39 +08:00
|
|
|
var JobRunner = require('./job-runner');
|
|
|
|
var QueryRunner = require('./query-runner');
|
|
|
|
var JobCanceller = require('./job-canceller');
|
2016-10-12 00:28:46 +08:00
|
|
|
var JobSubscriber = require('./pubsub/job-subscriber');
|
2019-10-04 00:24:39 +08:00
|
|
|
var UserDatabaseMetadataService = require('./user-database-metadata-service');
|
2016-10-12 00:28:46 +08:00
|
|
|
var JobPublisher = require('./pubsub/job-publisher');
|
2019-10-04 00:24:39 +08:00
|
|
|
var JobQueue = require('./job-queue');
|
|
|
|
var JobBackend = require('./job-backend');
|
|
|
|
var JobService = require('./job-service');
|
2016-09-29 21:09:36 +08:00
|
|
|
var BatchLogger = require('./batch-logger');
|
2016-01-08 18:32:01 +08:00
|
|
|
var Batch = require('./batch');
|
|
|
|
|
2016-10-17 21:02:34 +08:00
|
|
|
module.exports = function batchFactory (metadataBackend, redisPool, name, statsdClient, loggerPath) {
|
2016-10-13 03:32:29 +08:00
|
|
|
var userDatabaseMetadataService = new UserDatabaseMetadataService(metadataBackend);
|
|
|
|
|
2019-04-04 20:31:41 +08:00
|
|
|
var logger = new BatchLogger(loggerPath, 'batch-queries');
|
|
|
|
|
2017-04-04 01:26:21 +08:00
|
|
|
var jobSubscriber = new JobSubscriber(redisPool);
|
2016-10-17 21:02:34 +08:00
|
|
|
var jobPublisher = new JobPublisher(redisPool);
|
2016-10-12 01:41:58 +08:00
|
|
|
|
2019-04-04 20:31:41 +08:00
|
|
|
var jobQueue = new JobQueue(metadataBackend, jobPublisher, logger);
|
|
|
|
var jobBackend = new JobBackend(metadataBackend, jobQueue, logger);
|
|
|
|
var queryRunner = new QueryRunner(userDatabaseMetadataService, logger);
|
2018-05-30 23:36:55 +08:00
|
|
|
var jobCanceller = new JobCanceller();
|
2019-04-04 20:31:41 +08:00
|
|
|
var jobService = new JobService(jobBackend, jobCanceller, logger);
|
2016-10-21 20:35:24 +08:00
|
|
|
var jobRunner = new JobRunner(jobService, jobQueue, queryRunner, metadataBackend, statsdClient);
|
2016-01-08 18:32:01 +08:00
|
|
|
|
2016-10-11 01:46:07 +08:00
|
|
|
return new Batch(
|
|
|
|
name,
|
2017-04-04 01:26:21 +08:00
|
|
|
userDatabaseMetadataService,
|
2016-10-11 01:46:07 +08:00
|
|
|
jobSubscriber,
|
2016-10-12 18:26:50 +08:00
|
|
|
jobQueue,
|
2016-10-11 01:46:07 +08:00
|
|
|
jobRunner,
|
|
|
|
jobService,
|
2016-10-17 21:02:34 +08:00
|
|
|
redisPool,
|
2016-10-11 01:46:07 +08:00
|
|
|
logger
|
|
|
|
);
|
2016-01-08 18:32:01 +08:00
|
|
|
};
|