CartoDB-SQL-API/lib/batch/index.js

38 lines
1.4 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');
var JobService = require('./job-service');
var Batch = require('./batch');
module.exports = function batchFactory (metadataBackend, redisPool, name, statsdClient, logger) {
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
2019-12-24 01:19:08 +08:00
var jobQueue = new JobQueue(metadataBackend, jobPublisher, logger);
var jobBackend = new JobBackend(metadataBackend, jobQueue, logger);
var queryRunner = new QueryRunner(userDatabaseMetadataService, logger);
var jobCanceller = new JobCanceller();
var jobService = new JobService(jobBackend, jobCanceller, logger);
var jobRunner = new JobRunner(jobService, jobQueue, queryRunner, metadataBackend, statsdClient);
return new Batch(
name,
userDatabaseMetadataService,
jobSubscriber,
jobQueue,
jobRunner,
jobService,
2016-10-17 21:02:34 +08:00
redisPool,
logger
);
};