Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grpc-sdk): module inconsistency on momentary core unavailability #258

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraries/grpc-sdk/src/modules/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ export class Config extends ConduitModule<typeof ConfigDefinition> {
async watchModules() {
const self = this;
this.emitter.setMaxListeners(150);
self.emitter.emit('serving-modules-update', await self.moduleList().catch());
try {
const call = this.client!.watchModules({});
for await (const data of call) {
self.emitter.emit('serving-modules-update', data.modules);
}
} catch (error) {
// uncomment for debug when needed
// currently is misleading if left on
// ConduitGrpcSdk.Logger.warn('Connection to gRPC server closed');
self.coreLive = false;
ConduitGrpcSdk.Logger.warn('Core unhealthy');
}
}
}
31 changes: 12 additions & 19 deletions packages/core/src/config-manager/service-discovery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,19 @@ export class ServiceDiscovery {
}

moduleList(call: GrpcRequest<null>, callback: GrpcCallback<ModuleListResponse>) {
if (this.registeredModules.size !== 0) {
const modules: {
moduleName: string;
url: string;
serving: boolean;
}[] = [];
this.registeredModules.forEach((value: RegisteredModule, key: string) => {
modules.push({
moduleName: key,
url: value.address,
serving: value.serving,
});
const modules: {
moduleName: string;
url: string;
serving: boolean;
}[] = [];
this.registeredModules.forEach((value: RegisteredModule, key: string) => {
modules.push({
moduleName: key,
url: value.address,
serving: value.serving,
});
callback(null, { modules });
} else {
callback({
code: status.NOT_FOUND,
message: 'Modules not available',
});
}
});
callback(null, { modules });
}

watchModules(call: ServerWritableStream<void, ModuleListResponse>) {
Expand Down
Loading