feat(repos): 添加消息队列分发。BAK
This commit is contained in:
parent
5b2a017858
commit
7ea8505873
@ -1,7 +1,6 @@
|
|||||||
env: dev
|
env: dev
|
||||||
http:
|
http:
|
||||||
port: 7122
|
port: 7122
|
||||||
|
|
||||||
db:
|
db:
|
||||||
postgres:
|
postgres:
|
||||||
host: 192.168.31.194
|
host: 192.168.31.194
|
||||||
@ -9,5 +8,9 @@ db:
|
|||||||
database: fennec
|
database: fennec
|
||||||
username: fennec
|
username: fennec
|
||||||
password:
|
password:
|
||||||
|
redis:
|
||||||
|
mq:
|
||||||
|
host: localhost
|
||||||
|
port: 6379
|
||||||
workspaces:
|
workspaces:
|
||||||
root: '/Users/ivanli/Projects/fennec/workspaces'
|
root: '/Users/ivanli/Projects/fennec/workspaces'
|
@ -8,6 +8,7 @@ import { AppService } from './app.service';
|
|||||||
import { ProjectsModule } from './projects/projects.module';
|
import { ProjectsModule } from './projects/projects.module';
|
||||||
import { ReposModule } from './repos/repos.module';
|
import { ReposModule } from './repos/repos.module';
|
||||||
import configuration from './commons/config/configuration';
|
import configuration from './commons/config/configuration';
|
||||||
|
import { BullModule } from '@nestjs/bull';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -37,6 +38,16 @@ import configuration from './commons/config/configuration';
|
|||||||
}),
|
}),
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
}),
|
}),
|
||||||
|
BullModule.forRootAsync({
|
||||||
|
imports: [ConfigModule],
|
||||||
|
useFactory: async (configService: ConfigService) => ({
|
||||||
|
redis: {
|
||||||
|
host: configService.get<string>('redis.mq.host', 'localhost'),
|
||||||
|
port: configService.get<number>('redis.mq.port', 6379),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
inject: [ConfigService],
|
||||||
|
}),
|
||||||
ProjectsModule,
|
ProjectsModule,
|
||||||
ReposModule,
|
ReposModule,
|
||||||
],
|
],
|
||||||
|
1
src/repos/repos.constants.ts
Normal file
1
src/repos/repos.constants.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const WORKSPACE_ACTION = 'workspace-action';
|
@ -4,9 +4,17 @@ import { Project } from '../projects/project.entity';
|
|||||||
import { ReposResolver } from './repos.resolver';
|
import { ReposResolver } from './repos.resolver';
|
||||||
import { ReposService } from './repos.service';
|
import { ReposService } from './repos.service';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
|
import { BullModule } from '@nestjs/bull';
|
||||||
|
import { WORKSPACE_ACTION } from './repos.constants';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Project]), ConfigModule],
|
imports: [
|
||||||
|
TypeOrmModule.forFeature([Project]),
|
||||||
|
ConfigModule,
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: WORKSPACE_ACTION,
|
||||||
|
}),
|
||||||
|
],
|
||||||
providers: [ReposResolver, ReposService],
|
providers: [ReposResolver, ReposService],
|
||||||
})
|
})
|
||||||
export class ReposModule {}
|
export class ReposModule {}
|
||||||
|
8
src/repos/workspace-action.consumer.ts
Normal file
8
src/repos/workspace-action.consumer.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Process, Processor } from '@nestjs/bull';
|
||||||
|
import { WORKSPACE_ACTION } from './repos.constants';
|
||||||
|
|
||||||
|
@Processor(WORKSPACE_ACTION)
|
||||||
|
export class WorkspaceActionConsumer {
|
||||||
|
@Process()
|
||||||
|
async dispatch() {}
|
||||||
|
}
|
5
src/repos/workspace-action.model.ts
Normal file
5
src/repos/workspace-action.model.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { WorkspaceActions } from './workspace-actions.enum';
|
||||||
|
|
||||||
|
export class WorkspaceAction {
|
||||||
|
action: WorkspaceActions;
|
||||||
|
}
|
6
src/repos/workspace-actions.enum.ts
Normal file
6
src/repos/workspace-actions.enum.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export enum WorkspaceActions {
|
||||||
|
checkoutBranch = 'checkoutBranch',
|
||||||
|
checkoutCommit = 'checkoutCommit',
|
||||||
|
listLogs = 'listLogs',
|
||||||
|
listBranches = 'listBranches',
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user