CartoDB-SQL-API/batch/index.js

40 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
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');
var UserDatabaseMetadataService = require('./user_database_metadata_service');
2016-10-12 00:28:46 +08:00
var JobPublisher = require('./pubsub/job-publisher');
var JobQueue = require('./job_queue');
var JobBackend = require('./job_backend');
2016-05-14 00:50:55 +08:00
var JobService = require('./job_service');
var BatchLogger = require('./batch-logger');
var Batch = require('./batch');
2016-10-17 21:02:34 +08:00
module.exports = function batchFactory (metadataBackend, redisPool, name, statsdClient, loggerPath) {
var userDatabaseMetadataService = new UserDatabaseMetadataService(metadataBackend);
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
var jobQueue = new JobQueue(metadataBackend, jobPublisher);
var jobBackend = new JobBackend(metadataBackend, jobQueue);
var queryRunner = new QueryRunner(userDatabaseMetadataService);
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, metadataBackend, statsdClient);
var logger = new BatchLogger(loggerPath);
return new Batch(
name,
userDatabaseMetadataService,
jobSubscriber,
jobQueue,
jobRunner,
jobService,
2016-10-17 21:02:34 +08:00
redisPool,
logger
);
};