2016-01-08 18:32:01 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
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-10-12 00:28:46 +08:00
|
|
|
var JobSubscriber = require('./pubsub/job-subscriber');
|
2016-01-08 18:32:01 +08:00
|
|
|
var UserDatabaseMetadataService = require('./user_database_metadata_service');
|
2016-10-12 00:28:46 +08:00
|
|
|
var JobPublisher = require('./pubsub/job-publisher');
|
2016-01-08 18:32:01 +08:00
|
|
|
var JobQueue = require('./job_queue');
|
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-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
|
|
|
};
|