Skip to content

Commit

Permalink
Avoid global dyn rpc descriptor (#178)
Browse files Browse the repository at this point in the history
Mutating is fine, but ensure its scoped to the base server - someone might have multiple servers created somewhere inside their application with the same names - this currently would cause a conflict
  • Loading branch information
jackkleeman authored Nov 15, 2023
1 parent 7e505d9 commit d7d5949
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/server/base_restate_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export abstract class BaseRestateServer {
HostedGrpcServiceMethod<unknown, unknown>
> = {};
protected readonly discovery: ServiceDiscoveryResponse;
protected readonly dynrpcDescriptor: RpcServiceProtoMetadata;

protected constructor(protocolMode: ProtocolMode) {
this.discovery = {
Expand All @@ -71,6 +72,7 @@ export abstract class BaseRestateServer {
maxProtocolVersion: 0,
protocolMode: protocolMode,
};
this.dynrpcDescriptor = copyProtoMetadata(rpcServiceProtoMetadata);
}

protected addDescriptor(descriptor: ProtoMetadata) {
Expand Down Expand Up @@ -232,7 +234,7 @@ export abstract class BaseRestateServer {
name.length - serviceName.length - 1
);

const desc = dynrpcDescriptor;
const desc = this.dynrpcDescriptor;
const serviceGrpcSpec = keyed
? pushKeyedService(desc, name)
: pushUnKeyedService(desc, name);
Expand Down Expand Up @@ -555,5 +557,3 @@ function createStringKeyedMethodDescriptor(
desc.name = methodName;
return desc;
}

const dynrpcDescriptor = copyProtoMetadata(rpcServiceProtoMetadata);

0 comments on commit d7d5949

Please sign in to comment.