improve healthcheck service
This commit is contained in:
parent
ffd4108419
commit
b2e52f00f8
|
@ -24,12 +24,6 @@ import { AuthenticationPresenter } from './authentication.presenter';
|
|||
import { RpcValidationPipe } from '../../../../utils/pipes/rpc.validation-pipe';
|
||||
import { UsernamePresenter } from './username.presenter';
|
||||
|
||||
enum ServingStatus {
|
||||
UNKNOWN = 0,
|
||||
SERVING = 1,
|
||||
NOT_SERVING = 2,
|
||||
}
|
||||
|
||||
@UsePipes(
|
||||
new RpcValidationPipe({
|
||||
whitelist: true,
|
||||
|
@ -191,11 +185,4 @@ export class AuthenticationController {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
@GrpcMethod('Health', 'Check')
|
||||
async check(): Promise<{ status: ServingStatus }> {
|
||||
return {
|
||||
status: ServingStatus.SERVING,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
|
|||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { AuthenticationMessagerController } from './adapters/primaries/authentication-messager.controller';
|
||||
import { Messager } from './adapters/secondaries/messager';
|
||||
import { HealthController } from './adapters/primaries/health.controller';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -47,7 +48,11 @@ import { Messager } from './adapters/secondaries/messager';
|
|||
inject: [ConfigService],
|
||||
}),
|
||||
],
|
||||
controllers: [AuthenticationController, AuthenticationMessagerController],
|
||||
controllers: [
|
||||
AuthenticationController,
|
||||
AuthenticationMessagerController,
|
||||
HealthController,
|
||||
],
|
||||
providers: [
|
||||
AuthenticationProfile,
|
||||
UsernameProfile,
|
||||
|
|
Loading…
Reference in New Issue