add health service

This commit is contained in:
sbriat 2023-03-30 16:36:32 +02:00
parent 8f37218313
commit 726541bc7b
2 changed files with 30 additions and 0 deletions

View File

@ -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;
}

View File

@ -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,
};
}
}