Merge branch 'healthservice' into 'main'

add health service

See merge request v3/service/user!29
This commit is contained in:
Sylvain Briat 2023-03-30 14:41:52 +00:00
commit bb9d6db6a2
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,
};
}
}