fase(19): scheduling module refactor
This commit is contained in:
20
dist/main.js
vendored
20
dist/main.js
vendored
@@ -60,6 +60,13 @@ const OnFindingCreated_1 = require("./modules/integrations/application/event-han
|
||||
// Licensing module
|
||||
const RSALicenseValidator_1 = require("./modules/licensing/infrastructure/validators/RSALicenseValidator");
|
||||
const LicenseService_1 = require("./modules/licensing/application/LicenseService");
|
||||
// Scheduling module
|
||||
const KyselyScheduleRepository_1 = require("./modules/scheduling/infrastructure/repositories/KyselyScheduleRepository");
|
||||
const CreateScheduleCommand_1 = require("./modules/scheduling/application/commands/CreateScheduleCommand");
|
||||
const ToggleScheduleCommand_1 = require("./modules/scheduling/application/commands/ToggleScheduleCommand");
|
||||
const DeleteScheduleCommand_1 = require("./modules/scheduling/application/commands/DeleteScheduleCommand");
|
||||
const ListSchedulesQuery_1 = require("./modules/scheduling/application/queries/ListSchedulesQuery");
|
||||
const SchedulingService_1 = require("./modules/scheduling/application/SchedulingService");
|
||||
// Job queue
|
||||
const SQLiteJobQueue_1 = require("./jobs/SQLiteJobQueue");
|
||||
const ExplorationWorker_1 = require("./jobs/workers/ExplorationWorker");
|
||||
@@ -125,7 +132,7 @@ async function bootstrap() {
|
||||
// 11b. Licensing
|
||||
const licenseValidator = new RSALicenseValidator_1.RSALicenseValidator();
|
||||
const licenseService = new LicenseService_1.LicenseService(licenseValidator);
|
||||
// 11c. Integrations
|
||||
// 11c. Integrations (moved from 11d)
|
||||
const integrationRepo = new KyselyIntegrationRepository_1.KyselyIntegrationRepository(db);
|
||||
const webhookRepo = new KyselyWebhookEndpointRepository_1.KyselyWebhookEndpointRepository(db);
|
||||
const webhookDispatcher = new WebhookDispatcher_1.WebhookDispatcher(webhookRepo, logger);
|
||||
@@ -136,6 +143,14 @@ async function bootstrap() {
|
||||
jobQueue.registerHandler(ExplorationWorker_1.EXPLORATION_JOB_TYPE, (0, ExplorationWorker_1.createExplorationJobHandler)({ sessionRepo, eventBus, logger }));
|
||||
jobQueue.registerHandler(ReportWorker_1.REPORT_JOB_TYPE, (0, ReportWorker_1.createReportJobHandler)({ logger, reportRepository: reportRepo, findingRepository: findingRepo }));
|
||||
jobQueue.start();
|
||||
// 12b. Scheduling module (after job queue, since it enqueues jobs)
|
||||
const scheduleRepo = new KyselyScheduleRepository_1.KyselyScheduleRepository(db);
|
||||
const createSchedule = new CreateScheduleCommand_1.CreateScheduleCommand(scheduleRepo, eventBus);
|
||||
const toggleSchedule = new ToggleScheduleCommand_1.ToggleScheduleCommand(scheduleRepo, eventBus);
|
||||
const deleteSchedule = new DeleteScheduleCommand_1.DeleteScheduleCommand(scheduleRepo, eventBus);
|
||||
const listSchedules = new ListSchedulesQuery_1.ListSchedulesQuery(scheduleRepo);
|
||||
const schedulingService = new SchedulingService_1.SchedulingService(scheduleRepo, jobQueue, eventBus, logger);
|
||||
await schedulingService.start();
|
||||
// 13. HTTP server
|
||||
const app = (0, server_1.createServer)({
|
||||
config,
|
||||
@@ -146,6 +161,7 @@ async function bootstrap() {
|
||||
fuzzingDeps: { runFuzz, repository: fuzzRepo },
|
||||
reportingDeps: { generateReport, reportRepository: reportRepo, jobQueue },
|
||||
integrationsDeps: { integrationRepo, webhookRepo },
|
||||
schedulingDeps: { createSchedule, toggleSchedule, deleteSchedule, listSchedules, schedulingService, scheduleRepo },
|
||||
licenseService,
|
||||
authDeps: {
|
||||
registerCommand,
|
||||
@@ -183,6 +199,8 @@ async function bootstrap() {
|
||||
httpServer.close();
|
||||
// Close socket.io
|
||||
io.close();
|
||||
// Stop scheduling service
|
||||
schedulingService.stop();
|
||||
// Stop job queue and wait for active jobs
|
||||
jobQueue.pause();
|
||||
await jobQueue.waitForActive(30000);
|
||||
|
||||
Reference in New Issue
Block a user