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: proto v2 support #10788

Closed
wants to merge 37 commits into from
Closed

feat: proto v2 support #10788

wants to merge 37 commits into from

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Dec 15, 2021

Description

Closes: #10728


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added the C:x/genutil genutil module issues label Dec 15, 2021
@lgtm-com
Copy link

lgtm-com bot commented Dec 15, 2021

This pull request introduces 2 alerts when merging 93afb5f into 914af60 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable
  • 1 for Duplicate 'if' branches

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Let's change all the Marshal/Unmarshal methods to take proto.Message rather than interface{}

codec/codec.go Outdated
@@ -21,32 +21,32 @@ type (

BinaryCodec interface {
// Marshal returns binary encoding of v.
Marshal(o ProtoMarshaler) ([]byte, error)
Marshal(o interface{}) ([]byte, error)
Copy link
Contributor

@fdymylja fdymylja Dec 16, 2021

Choose a reason for hiding this comment

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

preliminary review - with @aaronc, we discussed to still keep the old proto.Message interface (the one in gogoproto) because our protov2 types implement that, and then try to promote a legacy proto.Message to the new proto.Message interface (the one with protoreflect)

Copy link
Contributor

Choose a reason for hiding this comment

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

nvm didn't see aaron already pointed that out! :D

@technicallyty
Copy link
Contributor Author

technicallyty commented Dec 22, 2021

having some trouble with marshaling an interface with golang/protobuf jsonpb marshaler.

the gogo version doesn't require a resolver and can marshal interfaces without it. The golang/protobuf needs a resolver, else it will fall back to the global registry, which is not used here.

the issue is fixed when using a resolver in the golang jsonpb marshaler, but our current interface registry seems tightly coupled with gogo's message interface, and changing it to golang's message interface seems to open a can of worms.. (it breaks our gateway code which is tied to gogo, and some scatterings of our codec).

any ideas on what to do here? @aaronc @fdymylja

see test showing the above here: d803846#diff-0f7a2f9aad8a3eb869cf813e0a06fcc45bea149d0d5480b0fb80ca6a73e1c6c5R209-R244

@lgtm-com
Copy link

lgtm-com bot commented Dec 22, 2021

This pull request introduces 2 alerts when merging 152faf0 into b67c4b3 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable
  • 1 for Duplicate 'if' branches

codec/json.go Outdated Show resolved Hide resolved
@aaronc
Copy link
Member

aaronc commented Jan 4, 2022

having some trouble with marshaling an interface with golang/protobuf jsonpb marshaler.

the gogo version doesn't require a resolver and can marshal interfaces without it. The golang/protobuf needs a resolver, else it will fall back to the global registry, which is not used here.

so is the issue primarily when an interface registry isn't explicitly specified?

the issue is fixed when using a resolver in the golang jsonpb marshaler, but our current interface registry seems tightly coupled with gogo's message interface, and changing it to golang's message interface seems to open a can of worms.. (it breaks our gateway code which is tied to gogo, and some scatterings of our codec).

how does it break the gateway code? proto.Message should be the same with both golang and gogo

@github-actions github-actions bot added the C:orm label Jan 21, 2022
@github-actions github-actions bot removed the C:x/genutil genutil module issues label Jan 21, 2022
@lgtm-com
Copy link

lgtm-com bot commented Jan 21, 2022

This pull request introduces 2 alerts when merging 62abf15 into fd5b97b - view on LGTM.com

new alerts:

  • 2 for Useless assignment to local variable

}

func (any *Any) UnmarshalJSONPB(u *jsonpb.Unmarshaler, bz []byte) error {
if string(bz) == "null" { // we return at this case since JSON will inject "null" for default value fields
Copy link
Contributor Author

@technicallyty technicallyty Jan 22, 2022

Choose a reason for hiding this comment

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

had to add this in, for some reason one of the JSON functions down the line is injecting "null" for empty Any slices ?? any idea if theres something better i can do here? @aaronc @fdymylja

@lgtm-com
Copy link

lgtm-com bot commented Jan 22, 2022

This pull request introduces 2 alerts when merging 4a4ef5b into 6ea2049 - view on LGTM.com

new alerts:

  • 2 for Useless assignment to local variable

@aaronc
Copy link
Member

aaronc commented Feb 28, 2022

@technicallyty how close was this to being ready? I wonder if we should try to push it through for 0.46

@technicallyty
Copy link
Contributor Author

@technicallyty how close was this to being ready? I wonder if we should try to push it through for 0.46

last i remember was being pretty stuck and not sure where to go next. i can try picking this up again but iirc wasn't 0.46 already delayed? not sure if we want to introduce something that could delay it again 🤔

@aaronc
Copy link
Member

aaronc commented Feb 28, 2022

@technicallyty how close was this to being ready? I wonder if we should try to push it through for 0.46

last i remember was being pretty stuck and not sure where to go next. i can try picking this up again but iirc wasn't 0.46 already delayed? not sure if we want to introduce something that could delay it again 🤔

Okay, let's postpone. If it was already working that would be a different story

@github-actions github-actions bot added C:CLI and removed C:orm labels Feb 28, 2022
@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 15, 2022
@github-actions github-actions bot closed this Apr 21, 2022
@tac0turtle tac0turtle deleted the ty/protov2-suppport branch February 16, 2023 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google.golang.org/protobuf support in Codec
3 participants