grpc-node
grpc-node copied to clipboard
grpc-loader: add method options in MethodDefinition
Add options and parsedOptions into MethodDefinition
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: hiepthai / name: Hiep Thai (a10471b1524f29317ac5cd05c8a413559efe22b4)
Can you send a corresponding PR to update this file with the new
MethodDefinitionfields?
Yeah sure, please check this out https://github.com/grpc/proposal/pull/328
Both of those fields seem to contain the same information; what is the purpose of adding both of them? What does each one provide that is missing from the other one?
I am also still concerned about the types of these fields. any is a very broad type, and I would much prefer to be clear about exactly what is in these fields, especially because this type needs to be re-exported by the gRPC library that it's used with.
I updated both MRs with new changes:
- unify
optionsandparsedOptionsintooptions, wont expose raw options anymore - add
MethodOptionsinterface - add test case
Waiting for your further feedback, thanks.
@murgatroid99 @hiepthai
been waiting for this feature to come out :) What's the status ?
If it's ok for @hiepthai, I can try to continue work on this PR.
Two questions mainly to @murgatroid99:
- Regarding "narrowest types possible": If I understand you correctly, e.g. for option
deprecatedyou would like to see justbooleanas type. This means if this option is not explicitly set totrueinside the proto file it will be returned asfalseby proto-loader. So we loose the information whether the option was actually set or not. Not set is interpreted the same as explicitly set tofalse. This is probably fine for most use cases but there might be some which would benefit from an exact representation of the proto file. E.g. for documentation-centric use cases. Is it acceptable to loose this precision or do we want to differenciate between not set/set? - What code controls if an option is interpreted (like
deprecatedandidempotency_level) or not (like(google.api.http))? Is this predefined by protobufjs? I'm asking because I thinkgoogle.api.httpis one of the most widely used options and it could make sense to make it easier to use.
- My assumption here is that protobuf options are handled the same way as protobuf message fields, meaning that the absence of a field is considered equivalent to setting it to the default value. I don't see any downside of doing that here: there's no meaningful difference between not explicitly deprecated and explicitly not deprecated, and there's no meaningful difference between unspecified
idempotency_levelandIDEMPOTENCY_UNKNOWN. - This distinction is in the official option definitions in descriptor.proto. The options officially defined by protobuf are "interpreted", and all others are "uninterpreted".
@murgatroid99, I created PR #2711 as a follow-up to this PR which tries to address your comments.
Superseded by #2711.