Merge branch 'improveHealth' into 'main'

improve healthcheck service

See merge request v3/service/user!30
This commit is contained in:
Sylvain Briat 2023-03-30 15:43:33 +00:00
commit 8bf2be24cc
3 changed files with 29 additions and 14 deletions

View File

@ -0,0 +1,27 @@
import { Controller } from '@nestjs/common';
import { GrpcMethod } from '@nestjs/microservices';
enum ServingStatus {
UNKNOWN = 0,
SERVING = 1,
NOT_SERVING = 2,
}
interface HealthCheckRequest {
service: string;
}
interface HealthCheckResponse {
status: ServingStatus;
}
@Controller()
export class HealthController {
@GrpcMethod('Health', 'Check')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
check(data: HealthCheckRequest, metadata: any): HealthCheckResponse {
return {
status: ServingStatus.SERVING,
};
}
}

View File

@ -24,12 +24,6 @@ import { UserPresenter } from './user.presenter';
import { ICollection } from '../../../database/src/interfaces/collection.interface';
import { RpcValidationPipe } from '../../../../utils/pipes/rpc.validation-pipe';
enum ServingStatus {
UNKNOWN = 0,
SERVING = 1,
NOT_SERVING = 2,
}
@UsePipes(
new RpcValidationPipe({
whitelist: true,
@ -129,11 +123,4 @@ export class UsersController {
throw new RpcException({});
}
}
@GrpcMethod('Health', 'Check')
async check(): Promise<{ status: ServingStatus }> {
return {
status: ServingStatus.SERVING,
};
}
}

View File

@ -5,6 +5,7 @@ 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';
@ -46,7 +47,7 @@ import { UserProfile } from './mappers/user.profile';
inject: [ConfigService],
}),
],
controllers: [UsersController],
controllers: [UsersController, HealthController],
providers: [
UserProfile,
UsersRepository,