update configuration module

This commit is contained in:
sbriat
2023-10-17 11:27:52 +02:00
parent a5fb44f9e4
commit a46d9416ad
6 changed files with 86 additions and 61 deletions

View File

@@ -1,2 +1,13 @@
// service
export const SERVICE_NAME = 'ad';
// configuration
export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set';
export const SERVICE_CONFIGURATION_DELETE_QUEUE = 'ad-configuration-delete';
export const SERVICE_CONFIGURATION_PROPAGATE_QUEUE =
'ad-configuration-propagate';
// health
export const HEALTH_SERVICE_NAME = 'health';
export const HEALTH_AD_REPOSITORY = 'AdRepository';
export const HEALTH_CRITICAL_LOGGING_KEY = 'logging.ad.health.crit';

View File

@@ -13,7 +13,14 @@ import { AD_REPOSITORY } from '@modules/ad/ad.di-tokens';
import { MESSAGE_PUBLISHER } from '@modules/messager/messager.di-tokens';
import { HealthModuleOptions } from '@mobicoop/health-module/dist/core/domain/types/health.types';
import { MessagePublisherPort } from '@mobicoop/ddd-library';
import { HEALTH_CRITICAL_LOGGING_KEY, SERVICE_NAME } from './app.constants';
import {
HEALTH_AD_REPOSITORY,
HEALTH_CRITICAL_LOGGING_KEY,
SERVICE_CONFIGURATION_DELETE_QUEUE,
SERVICE_CONFIGURATION_PROPAGATE_QUEUE,
SERVICE_CONFIGURATION_SET_QUEUE,
SERVICE_NAME,
} from './app.constants';
@Module({
imports: [
@@ -31,18 +38,23 @@ import { HEALTH_CRITICAL_LOGGING_KEY, SERVICE_NAME } from './app.constants';
) as string,
messageBroker: {
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
exchange: configService.get<string>(
'MESSAGE_BROKER_EXCHANGE',
) as string,
exchange: {
name: configService.get<string>(
'MESSAGE_BROKER_EXCHANGE',
) as string,
durable: configService.get<boolean>(
'MESSAGE_BROKER_EXCHANGE_DURABILITY',
) as boolean,
},
},
redis: {
host: configService.get<string>('REDIS_HOST') as string,
password: configService.get<string>('REDIS_PASSWORD'),
port: configService.get<number>('REDIS_PORT') as number,
},
setConfigurationBrokerQueue: 'ad-configuration-create-update',
deleteConfigurationQueue: 'ad-configuration-delete',
propagateConfigurationQueue: 'ad-configuration-propagate',
setConfigurationQueue: SERVICE_CONFIGURATION_SET_QUEUE,
deleteConfigurationQueue: SERVICE_CONFIGURATION_DELETE_QUEUE,
propagateConfigurationQueue: SERVICE_CONFIGURATION_PROPAGATE_QUEUE,
}),
}),
HealthModule.forRootAsync({
@@ -56,7 +68,7 @@ import { HEALTH_CRITICAL_LOGGING_KEY, SERVICE_NAME } from './app.constants';
criticalLoggingKey: HEALTH_CRITICAL_LOGGING_KEY,
checkRepositories: [
{
name: 'AdRepository',
name: HEALTH_AD_REPOSITORY,
repository: adRepository,
},
],

View File

@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { join } from 'path';
import { AppModule } from './app.module';
import { HEALTH_SERVICE_NAME, SERVICE_NAME } from './app.constants';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
@@ -11,7 +12,7 @@ async function bootstrap() {
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.GRPC,
options: {
package: ['ad', 'health'],
package: [SERVICE_NAME, HEALTH_SERVICE_NAME],
protoPath: [
join(__dirname, 'modules/ad/interface/grpc-controllers/ad.proto'),
join(__dirname, 'health.proto'),

View File

@@ -10,6 +10,7 @@ import {
} from '@mobicoop/ddd-library';
import { PrismaService } from './prisma.service';
import { AD_MESSAGE_PUBLISHER } from '../ad.di-tokens';
import { SERVICE_NAME } from '@src/app.constants';
export type AdBaseModel = {
uuid: string;
@@ -86,7 +87,7 @@ export class AdRepository
eventEmitter,
new LoggerBase({
logger: new Logger(AdRepository.name),
domain: 'ad',
domain: SERVICE_NAME,
messagePublisher,
}),
);