Support protobuf editions, allow edition 2023 #403
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.
Protobuf is moving to editions as a replacement for the syntax definition, and has defined a 2023 edition that is the successor to proto2/proto3 syntax. Go protobuf got a new Opaque API as well, that is tied to edition 2023.
Tooling needs to declare support for both editions, and what editions are supported. Currently
protoc-gen-twirp
does not, so using a 2023 edition file results in:This resolves that by declaring that the plugin supports editions. The max supported edition is set to 2023, the latest released. This can be incremented as needed, once it's ensured that the new edition doesn't introduce any issues or breaking changes.
From a Twirp perspective, edition 2023 appears to introduce nothing that needs to be handled in its generated code. The service definitions are untouched, just message fields. Twirp doesn't interact with these directly.
I waffled a bit on testing this. Like in #332, nothing that Twirp interacts with directly changes. We could maybe add a second 2023 edition proto definition to the clientcompat tests and switch between them with build tags or something, but I think that would be testing protobuf's ability to serialize/deserialize more than Twirp itself. Happy to try that / react to feedback though.
The example was also left as
proto3
, as editions support is fairly new and I didn't want to force anyone using that to have to update immediately.Note: This PR requires the updates in #402 to function.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.