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-01-08 18:32:01 +08:00
|
|
|
var Batch = require('./batch');
|
|
|
|
|
2020-06-30 23:42:59 +08:00
|
|
|
module.exports = function batchFactory (metadataBackend, redisPool, name, statsdClient, logger) {
|
2016-10-13 03:32:29 +08:00
|
|
|
var userDatabaseMetadataService = new UserDatabaseMetadataService(metadataBackend);
|
|
|
|
|
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-12-24 01:19:08 +08:00
|
|
|
var jobQueue = new JobQueue(metadataBackend, jobPublisher, logger);
|
2019-04-04 20:31:41 +08:00
|
|
|
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
|
|
|
};
|