import { Module } from '@nestjs/common'; import { PipelineTasksService } from './pipeline-tasks.service'; import { PipelineTasksResolver } from './pipeline-tasks.resolver'; import { TypeOrmModule } from '@nestjs/typeorm'; import { PipelineTask } from './pipeline-task.entity'; import { Pipeline } from '../pipelines/pipeline.entity'; import { ReposModule } from '../repos/repos.module'; import { RedisModule } from 'nestjs-redis'; import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { PipelineTaskRunner } from './pipeline-task.runner'; import { spawn } from 'child_process'; import { EXCHANGE_PIPELINE_TASK_FANOUT } from './pipeline-tasks.constants'; import { PipelineTaskLogger } from './pipeline-task.logger'; @Module({ imports: [ TypeOrmModule.forFeature([PipelineTask, Pipeline]), RedisModule, ReposModule, RabbitMQModule.forRootAsync(RabbitMQModule, { imports: [ConfigModule], useFactory: (configService: ConfigService) => ({ uri: configService.get('db.rabbitmq.uri'), exchanges: [ { name: 'new-pipeline-task', type: 'fanout', options: { durable: true, autoDelete: true, }, }, { name: 'stop-pipeline-task', type: 'fanout', options: { durable: true, autoDelete: true, }, }, { name: 'update-pipeline-task', type: 'fanout', options: { durable: false, autoDelete: true, }, }, { name: EXCHANGE_PIPELINE_TASK_FANOUT, type: 'fanout', options: { durable: false, autoDelete: true, }, }, ], }), inject: [ConfigService], }), ], providers: [ PipelineTasksService, PipelineTasksResolver, PipelineTaskRunner, PipelineTaskLogger, { provide: 'spawn', useValue: spawn, }, ], exports: [PipelineTasksService], }) export class PipelineTasksModule {}