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-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');
|
|
|
|
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-01-08 18:32:01 +08:00
|
|
|
var Batch = require('./batch');
|
|
|
|
|
|
|
|
module.exports = function batchFactory (metadataBackend) {
|
2016-01-23 02:31:25 +08:00
|
|
|
var jobSubscriber = new JobSubscriber(redis);
|
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);
|
|
|
|
var jobRunner = new JobRunner(jobBackend, userDatabaseMetadataService);
|
2016-01-13 23:25:25 +08:00
|
|
|
var jobCanceller = new JobCanceller(metadataBackend, userDatabaseMetadataService, jobBackend);
|
2016-01-08 18:32:01 +08:00
|
|
|
|
2016-01-13 23:25:25 +08:00
|
|
|
return new Batch(jobSubscriber, jobQueuePool, jobRunner, jobCanceller);
|
2016-01-08 18:32:01 +08:00
|
|
|
};
|