-
Notifications
You must be signed in to change notification settings - Fork 45
pb: Add ProtobufConfig with discardUnknownFields configuration
#569
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
base: grpc-common
Are you sure you want to change the base?
Conversation
5579897 to
775e741
Compare
Mr3zee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant two nls
| * val myCodec = codec<MyMessage>(config) | ||
| * | ||
| * // Or pass config per-operation | ||
| * val decoded = codec.decode(stream, ProtobufConfig(discardUnknownFields = true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be shorter with codec.decode(stream, config) (config is from the line above)
| } | ||
|
|
||
| encoder.writeMessage(1, firstPart as OtherInternal) { encodeWith(encoder) } | ||
| encoder.writeMessage(1, firstPart as OtherInternal) { encodeWith(encoder, null) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the parameter be with a default null value?
Mr3zee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Subsystem
Protobuf
Problem Description
Currently, it is not possible to tell the protobuf decoder to discard unknown fields during message parsing.
Solution
This PR adds the
ProtobufConfigclass that holds thediscardUnknownFieldsproperty.If passed to the
MessageCodec, it tells the generated protobuf decoder to discard unknown fields.