Добавлен вызов issue-cache-writer из event-emitter
This commit is contained in:
parent
fd0f1fc1f7
commit
954adde14e
1 changed files with 26 additions and 3 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import { EventEmitterModule } from '@app/event-emitter';
|
||||
import { MainController } from '@app/event-emitter/main/main.controller';
|
||||
import { RedmineIssuesCacheWriterModule } from '@app/redmine-issues-cache-writer';
|
||||
import { Module } from '@nestjs/common';
|
||||
import {
|
||||
RedmineIssuesCacheWriterModule,
|
||||
RedmineIssuesCacheWriterService,
|
||||
} from '@app/redmine-issues-cache-writer';
|
||||
import { Logger, Module, OnModuleInit } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { Issues } from './datasources/issues';
|
||||
import configuration from './configs/app';
|
||||
import { RedmineEventsGateway } from '@app/event-emitter/events/redmine-events.gateway';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
|
@ -19,4 +23,23 @@ import configuration from './configs/app';
|
|||
controllers: [AppController, MainController],
|
||||
providers: [AppService, Issues],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule implements OnModuleInit {
|
||||
private logger = new Logger(AppModule.name);
|
||||
|
||||
constructor(
|
||||
private redmineEventsGateway: RedmineEventsGateway,
|
||||
private redmineIssuesCacheWriterService: RedmineIssuesCacheWriterService,
|
||||
) {}
|
||||
|
||||
onModuleInit() {
|
||||
const queue = this.redmineEventsGateway.getIssuesChangesQueue();
|
||||
const subj = queue.queue;
|
||||
subj.subscribe(async (issue: any) => {
|
||||
try {
|
||||
this.redmineIssuesCacheWriterService.saveIssue(issue);
|
||||
} catch (ex) {
|
||||
this.logger.error(`Saving issue error - ${ex}`, null, { issue: issue });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue