Skip to content

Add package definition loader function to native package#196

Merged
murgatroid99 merged 2 commits intogrpc:masterfrom
murgatroid99:package_definition_loader
Feb 27, 2018
Merged

Add package definition loader function to native package#196
murgatroid99 merged 2 commits intogrpc:masterfrom
murgatroid99:package_definition_loader

Conversation

@murgatroid99
Copy link
Copy Markdown
Member

@kjin This is the implementation in the existing native library of the function to load the "package definition" from the protobuf library. As you can see, it calls makeClientConstructor, which is the other function that is not currently implemented in the pure JavaScript implementation.

The result type for this looks something like

type GrpcPackage = {
  [name: string]: GrpcPackage | typeof Client
}

for (const serviceFqn in packageDef) {
const service = packageDef[serviceFqn];
const nameComponents = serviceFqn.split('.');
const serviceName = nameComponents[-1];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean nameComponents.slice(-1)[0]?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, something like that. I forgot that wasn't a thing in JavaScript.

@murgatroid99 murgatroid99 merged commit 01ce272 into grpc:master Feb 27, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants