-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add New ProtobufEncodingMode for Nullable and Google-Compatible Types #374
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, field numbers were always assigned automatically during protobuf schema generation, based on declaration order of properties in a data class. It is very easy to modify the data class in a way that changes field numbers unintentionally, which introduces a breaking change to the protobuf schema. This commit introduces the annotation `@ProtobufField` as a mechanism for explicitly providing field numbers, as well as a `FieldNumberStrategy` enum (used in `@ProtobufGen.fieldNumberStrategy`) to select how field numbers should be assigned. There's a manual strategy and two automatic strategies. Further, `@ProtobufGen.reservedFieldNumbers` and `reservedFieldNames` allow specifying reserved field numbers / names, similarly to the protobuf language itself. Reserved field numbers and names are verified at compile time. The fields in the protobuf schema are generated in the field number order, not in the property declaration order. The serialization/deserialization code in generated converters also uses field number order. This is to make sure that a Vert.x-generated and `protoc`-generated serializers produce outputs that are not just mutually _compatible_, but also binary _identical_.
is this ready for review @lwlee2608 ? |
@vietj yes |
vietj
reviewed
Oct 20, 2023
vertx-codegen-protobuf/src/main/java/io/vertx/codegen/protobuf/ProtobufEncodingMode.java
Show resolved
Hide resolved
vietj
approved these changes
Oct 20, 2023
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.
just a minor rename
…lution Introduce mechanism for specifying protobuf field numbers
…rtx-codegen into compatibility-check
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
ProtobufEncodingMode
VERTX_NULLABLE,
In this encoding mode, the converter uses a non-standard protobuf encoding to allow boxed types (e.g., Integer, Double) and String to be nullable. This encoding mode is intended for use when communicating with another Vert.x converter that supports nullable values.
GOOGLE_COMPATIBLE
In this encoding mode, the converter uses the standard protobuf encoding, which is compatible with Google's protobuf ecoder. Null values are not allowed for boxed types and String in this mode.