From 726541bc7b3d8ef210dafd8275654fb4994e499a Mon Sep 17 00:00:00 2001 From: sbriat Date: Thu, 30 Mar 2023 16:36:32 +0200 Subject: [PATCH] add health service --- src/modules/users/adapters/primaries/user.proto | 17 +++++++++++++++++ .../adapters/primaries/users.controller.ts | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/modules/users/adapters/primaries/user.proto b/src/modules/users/adapters/primaries/user.proto index a579285..0a629d6 100644 --- a/src/modules/users/adapters/primaries/user.proto +++ b/src/modules/users/adapters/primaries/user.proto @@ -33,3 +33,20 @@ 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; +} diff --git a/src/modules/users/adapters/primaries/users.controller.ts b/src/modules/users/adapters/primaries/users.controller.ts index b48d00f..562251c 100644 --- a/src/modules/users/adapters/primaries/users.controller.ts +++ b/src/modules/users/adapters/primaries/users.controller.ts @@ -24,6 +24,12 @@ 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, @@ -123,4 +129,11 @@ export class UsersController { throw new RpcException({}); } } + + @GrpcMethod('Health', 'Check') + async check(): Promise<{ status: ServingStatus }> { + return { + status: ServingStatus.SERVING, + }; + } }