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

L23: Add options & parsedOptions into MethodDefinition #328

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions L23-node-protobufjs-library.md
Expand Up @@ -4,7 +4,7 @@ Standalone Node.js gRPC+Protobuf.js Library API
* Approver: wenbozhu
* Status: Ready for Implementation
* Implemented in: Node.js
* Last updated: 2019-05-15
* Last updated: 2022-09-21
* Discussion at: https://groups.google.com/forum/#!topic/grpc-io/t7XFE7Wevow

## Abstract
Expand All @@ -17,7 +17,7 @@ The Node gRPC library currently depends on Protobuf.js version 5. Since Protobuf

## Proposal

For the purpose of definiing services in general, the existing gRPC library has defined the types [`MethodDefinition`](https://grpc.io/grpc/node/grpc.html#~MethodDefinition__anchor) and [`ServiceDefinition`](https://grpc.io/grpc/node/grpc.html#~ServiceDefinition__anchor). A `MethodDefinition` is an object with the following properties:
For the purpose of defining services in general, the existing gRPC library has defined the types [`MethodDefinition`](https://grpc.io/grpc/node/grpc.html#~MethodDefinition__anchor) and [`ServiceDefinition`](https://grpc.io/grpc/node/grpc.html#~ServiceDefinition__anchor). A `MethodDefinition` is an object with the following properties:

- `path`: The URL path for accessing this method
- `requestStream`: A boolean indicating whether there is a stream of request messages instead of a single message.
Expand All @@ -26,6 +26,7 @@ For the purpose of definiing services in general, the existing gRPC library has
- `responseSerialize`: A function for serializing a response object to a `Buffer`
- `requestDeserialize`: A function for deserializing a request object from a `Buffer`
- `responseDeserialize`: A function for deserializing a response object from a `Buffer`
- `options`: Method options object

This information is sufficient to implement a client or service handler for any kind of method. Then a `ServiceDefintion` is just an object that maps method names to `MethodDefinition` objects. When loading a `.proto` file, more than one service may be loaded, so we additionally define a wrapping type `PackageDefinition`, which maps fully qualified service names to `ServiceDefinition` objects. For example, if a `.proto` file defines the package `a.b` with the services `Service1` and `Service2`, the resulting `PackageDefinition` would have the keys `"a.b.Service1"` and `"a.b.Service2"`.

Expand Down