2021-03-01 18:14:13 +08:00
|
|
|
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';
|
2021-03-04 11:43:23 +08:00
|
|
|
import { ReposModule } from '../repos/repos.module';
|
2021-03-06 12:23:55 +08:00
|
|
|
import { RedisModule } from 'nestjs-redis';
|
2021-05-23 17:51:14 +08:00
|
|
|
import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
import { PipelineTaskRunner } from './pipeline-task.runner';
|
|
|
|
import { spawn } from 'child_process';
|
2021-03-01 18:14:13 +08:00
|
|
|
|
|
|
|
@Module({
|
2021-03-06 12:23:55 +08:00
|
|
|
imports: [
|
|
|
|
TypeOrmModule.forFeature([PipelineTask, Pipeline]),
|
|
|
|
RedisModule,
|
|
|
|
ReposModule,
|
2021-05-23 17:51:14 +08:00
|
|
|
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'stop-pipeline-task',
|
|
|
|
type: 'fanout',
|
|
|
|
options: {
|
|
|
|
durable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'update-pipeline-task',
|
|
|
|
type: 'fanout',
|
|
|
|
options: {
|
|
|
|
durable: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
inject: [ConfigService],
|
|
|
|
}),
|
2021-03-06 12:23:55 +08:00
|
|
|
],
|
2021-03-12 23:00:12 +08:00
|
|
|
providers: [
|
|
|
|
PipelineTasksService,
|
|
|
|
PipelineTasksResolver,
|
2021-05-23 17:51:14 +08:00
|
|
|
PipelineTaskRunner,
|
|
|
|
{
|
|
|
|
provide: 'spawn',
|
|
|
|
useValue: spawn,
|
|
|
|
},
|
2021-03-12 23:00:12 +08:00
|
|
|
],
|
2021-03-28 10:24:12 +08:00
|
|
|
exports: [PipelineTasksService],
|
2021-03-01 18:14:13 +08:00
|
|
|
})
|
|
|
|
export class PipelineTasksModule {}
|