feat-pipelines #1

Merged
Ivan merged 25 commits from feat-pipelines into master 2021-03-24 20:50:41 +08:00
4 changed files with 34 additions and 2 deletions
Showing only changes of commit 38d3cb0db8 - Show all commits

View File

@ -9,5 +9,10 @@ db:
database: fennec
username: fennec
password:
redis:
host: 192.168.31.194
port: 6379
password:
prefix: fennec
workspaces:
root: '/Users/ivanli/Projects/fennec/workspaces'

View File

@ -10,6 +10,7 @@ import { ReposModule } from './repos/repos.module';
import { PipelinesModule } from './pipelines/pipelines.module';
import { PipelineTasksModule } from './pipeline-tasks/pipeline-tasks.module';
import configuration from './commons/config/configuration';
import { RedisModule } from 'nestjs-redis';
@Module({
imports: [
@ -43,6 +44,16 @@ import configuration from './commons/config/configuration';
ReposModule,
PipelinesModule,
PipelineTasksModule,
RedisModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
host: configService.get<string>('db.redis.host', 'localhost'),
port: configService.get<number>('db.redis.port', 6379),
password: configService.get<string>('db.redis.password', ''),
keyPrefix: configService.get<string>('db.redis.prefix', 'fennec'),
}),
inject: [ConfigService],
}),
],
controllers: [AppController],
providers: [AppService, AppResolver],

View File

@ -5,9 +5,25 @@ 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 { BullModule } from '@nestjs/bull';
import {
PIPELINE_TASK_QUEUE,
PIPELINE_TASK_LOG_QUEUE,
} from './pipeline-tasks.constants';
@Module({
imports: [TypeOrmModule.forFeature([PipelineTask, Pipeline]), ReposModule],
imports: [
TypeOrmModule.forFeature([PipelineTask, Pipeline]),
BullModule.registerQueue(
{
name: PIPELINE_TASK_QUEUE,
},
{ name: PIPELINE_TASK_LOG_QUEUE },
),
RedisModule,
ReposModule,
],
providers: [PipelineTasksService, PipelineTasksResolver],
})
export class PipelineTasksModule {}

View File

@ -17,9 +17,9 @@ export class PipelineTasksService {
private readonly repository: Repository<PipelineTask>,
@InjectRepository(Pipeline)
private readonly pipelineRepository: Repository<Pipeline>,
private readonly redis: RedisService,
@InjectQueue(PIPELINE_TASK_QUEUE)
private readonly queue: Queue<PipelineTask>,
private readonly redis: RedisService,
) {}
async addTask(dto: CreatePipelineTaskInput) {
const pipeline = await this.pipelineRepository.findOneOrFail({