73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
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,
|
|
EXCHANGE_PIPELINE_TASK_TOPIC,
|
|
} from './pipeline-tasks.constants';
|
|
import { PipelineTaskLogger } from './pipeline-task.logger';
|
|
import { PipelineTaskFlushService } from './pipeline-task-flush.service';
|
|
|
|
@Module({
|
|
imports: [
|
|
TypeOrmModule.forFeature([PipelineTask, Pipeline]),
|
|
RedisModule,
|
|
ReposModule,
|
|
RabbitMQModule.forRootAsync(RabbitMQModule, {
|
|
imports: [ConfigModule],
|
|
useFactory: (configService: ConfigService) => ({
|
|
uri: configService.get<string>('db.rabbitmq.uri'),
|
|
exchanges: [
|
|
{
|
|
name: 'new-pipeline-task',
|
|
type: 'fanout',
|
|
options: {
|
|
durable: true,
|
|
autoDelete: true,
|
|
},
|
|
},
|
|
{
|
|
name: EXCHANGE_PIPELINE_TASK_FANOUT,
|
|
type: 'fanout',
|
|
options: {
|
|
durable: false,
|
|
autoDelete: true,
|
|
},
|
|
},
|
|
{
|
|
name: EXCHANGE_PIPELINE_TASK_TOPIC,
|
|
type: 'topic',
|
|
options: {
|
|
durable: false,
|
|
autoDelete: true,
|
|
},
|
|
},
|
|
],
|
|
}),
|
|
inject: [ConfigService],
|
|
}),
|
|
],
|
|
providers: [
|
|
PipelineTasksService,
|
|
PipelineTasksResolver,
|
|
PipelineTaskRunner,
|
|
PipelineTaskLogger,
|
|
{
|
|
provide: 'spawn',
|
|
useValue: spawn,
|
|
},
|
|
PipelineTaskFlushService,
|
|
],
|
|
exports: [PipelineTasksService],
|
|
})
|
|
export class PipelineTasksModule {}
|