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

feat: support google.golang.org/protobuf #119

Merged
merged 6 commits into from
Apr 4, 2024
Merged

feat: support google.golang.org/protobuf #119

merged 6 commits into from
Apr 4, 2024

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Mar 22, 2024

This adds support for:

  • marshaling/unmarshaling google.golang.org/protobuf/proto.Message types
  • jsonpb marshaling/unmarshaling these types
  • getting the message name for these types using MessageName

This should remove any incompatibilties or need for type switching the SDK has when using these types.

Given that gogo proto already does a bunch of type switches to see what kind of message is used, this support seems reasonable and goes a long way to providing v2 support for anyone who wants it (we will use this at Regen at least and others will have a choice). Basically, this makes v2 types more with the v1 APIs the SDK uses without needing to change anything on the SDK side.

@aaronc aaronc marked this pull request as ready for review March 22, 2024 16:03
@aaronc aaronc requested a review from a team as a code owner March 22, 2024 16:04
@kocubinski kocubinski self-assigned this Mar 23, 2024
@@ -128,6 +131,19 @@ type JSONPBUnmarshaler interface {

// Marshal marshals a protocol buffer into JSON.
func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error {
if msgV2, ok := pb.(protov2.Message); ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the thinking behind placing this v2 code path (and early return) before the nil and required field checks below which the v1 code path follows?

Copy link
Member Author

@aaronc aaronc Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That stuff except for maybe the nil check would be invalid for v2. Also this is for jsonpb so not performance critical - it's only used on the cli I believe.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get a changelog?

@aaronc
Copy link
Member Author

aaronc commented Mar 31, 2024

can we get a changelog?

Added

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! We should alias MsgTypeUrl from core and codec in the SDK to this (+ /) 🙏

@julienrbrt julienrbrt merged commit 3dec704 into main Apr 4, 2024
3 checks passed
@julienrbrt julienrbrt deleted the aaronc/v2 branch April 4, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants