extract health to module

This commit is contained in:
sbriat 2023-03-31 10:10:31 +02:00
parent 8bf2be24cc
commit da2e365455
7 changed files with 36 additions and 24 deletions

View File

@ -3,6 +3,7 @@ import { AutomapperModule } from '@automapper/nestjs';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ConfigurationModule } from './modules/configuration/configuration.module';
import { HealthModule } from './modules/health/health.module';
import { UsersModule } from './modules/users/users.module';
@Module({
@ -11,6 +12,7 @@ import { UsersModule } from './modules/users/users.module';
AutomapperModule.forRoot({ strategyInitializer: classes() }),
UsersModule,
ConfigurationModule,
HealthModule,
],
controllers: [],
providers: [],

View File

@ -9,11 +9,11 @@ async function bootstrap() {
{
transport: Transport.GRPC,
options: {
package: 'user',
protoPath: join(
__dirname,
'modules/users/adapters/primaries/user.proto',
),
package: ['user', 'health'],
protoPath: [
join(__dirname, 'modules/users/adapters/primaries/user.proto'),
join(__dirname, 'modules/health/adapters/primaries/health.proto'),
],
url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT,
loader: { keepCase: true },
},

View File

@ -0,0 +1,21 @@
syntax = "proto3";
package health;
service Health {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
}
message HealthCheckRequest {
string service = 1;
}
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
}
ServingStatus status = 1;
}

View File

@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { HealthController } from './adapters/primaries/health.controller';
@Module({
controllers: [HealthController],
})
export class HealthModule {}

View File

@ -33,20 +33,3 @@ message Users {
}
message Empty {}
service Health {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
}
message HealthCheckRequest {
string service = 1;
}
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
}
ServingStatus status = 1;
}

View File

@ -5,7 +5,6 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
import { CqrsModule } from '@nestjs/cqrs';
import { redisStore } from 'cache-manager-ioredis-yet';
import { DatabaseModule } from '../database/database.module';
import { HealthController } from './adapters/primaries/health.controller';
import { UsersController } from './adapters/primaries/users.controller';
import { Messager } from './adapters/secondaries/messager';
import { UsersRepository } from './adapters/secondaries/users.repository';
@ -47,7 +46,7 @@ import { UserProfile } from './mappers/user.profile';
inject: [ConfigService],
}),
],
controllers: [UsersController, HealthController],
controllers: [UsersController],
providers: [
UserProfile,
UsersRepository,