mirror of
https://gitlab.com/mobicoop/v3/service/user.git
synced 2025-12-31 18:22:39 +00:00
extract health to module
This commit is contained in:
27
src/modules/health/adapters/primaries/health.controller.ts
Normal file
27
src/modules/health/adapters/primaries/health.controller.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
}
|
||||
21
src/modules/health/adapters/primaries/health.proto
Normal file
21
src/modules/health/adapters/primaries/health.proto
Normal 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;
|
||||
}
|
||||
7
src/modules/health/health.module.ts
Normal file
7
src/modules/health/health.module.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HealthController } from './adapters/primaries/health.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [HealthController],
|
||||
})
|
||||
export class HealthModule {}
|
||||
Reference in New Issue
Block a user