ConduitPlatform / Conduit

Batteries-included backend that works with any stack.

Home Page:https://getconduit.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEAT] Support proper Health Checking

kkopanidis opened this issue · comments

Is your feature request related to a problem? Please describe.
Currently health checking is being done by this simple process:

private async _registerModule(
moduleName: string,
moduleUrl: string,
instancePeer: string,
fromGrpc = false
) {
let dbInit = false;
if (!fromGrpc) {
let failed: any;
await axios.get('http://' + moduleUrl).catch((err: any) => {
failed = err;
});
if (failed && failed.message.indexOf('Parse Error') === -1) {
throw new Error('Failed to register dead module');
}
}
if (
moduleName === 'database' &&
this.registeredModules.has('database')
) {
dbInit = true;
}
this.registeredModules.set(moduleName, moduleUrl);
if (moduleName === 'database' && !dbInit) {
this.databaseCallback();
}
this.updateModuleHealth(moduleName, instancePeer);
this.moduleRegister.emit('module-registered');
}

It works well enough, but it's not common practice and it simply checks if the grpc server is online. We're getting no proper health statuses and we're using an http client to check a grpc server which isn't really that great.

Describe the solution you'd like
The modules should implement (through the grpc-sdk) the Health Checking protocol of grpc as defined here:
https://github.com/grpc/grpc/blob/master/doc/health-checking.md

The config module should then be able to use the Watch rpc stream to get health status updates or at the very list make individual requests (as it's happening now but through grpc) to get better sense of the actual service status.

It'll also be more in line with common practices around grpc