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

all: investigate and document Proto v2 API usage #1815

Closed
tbpg opened this issue Mar 4, 2020 · 3 comments
Closed

all: investigate and document Proto v2 API usage #1815

tbpg opened this issue Mar 4, 2020 · 3 comments
Assignees
Labels
type: docs Improvement to the documentation for an API.

Comments

@tbpg
Copy link
Contributor

tbpg commented Mar 4, 2020

http://google.golang.org/protobuf is the v2 version of http://github.com/golang/protobuf.

We should investigate how we can/should use it for cloud.google.com/go (among other Go repos).

We might also want to see if there is a way clients could use v2, even if our repos can't directly switch to v2.

We should also publish something in the root README saying what the plan is.

@tbpg tbpg added the type: docs Improvement to the documentation for an API. label Mar 4, 2020
@tbpg
Copy link
Contributor Author

tbpg commented Mar 4, 2020

cc @neild and @dsnet

@dsnet
Copy link
Contributor

dsnet commented Mar 10, 2020

There should be relatively little public affect to using the newer API. Most of the protobuf usage is within the internal implementation, the only place places where the old API leaks to the exported API are in the following two packages:

where the older proto.Message interface is exposed in the public API. Fortunately, both packages are explicitly marked as "experimental and subject to change".

To upgrade to using the new API, I recommend doing the following:

  • Upgrade to github.com/golang/protobuf@v1.4.0-rc.4 (this uses google.golang.org/protobuf@v1.20.0 under the hood).
  • Run tests and make sure everything works.
  • Regenerate all .pb.go files with protoc-gen-go@v1.4.0-rc.4.
  • Run tests and make sure everything works. You may need to fix some brittle tests accidentally relying on unspecified behavior. See the release notes regarding generated code.
  • Migrate the internal implementation to use the new API directly. By far, the most commonly used functions are proto.Equal and proto.Clone, both of which should be almost drop-in replaceable with the new API. The only difference is that the new API takes in the new Message interface. If you re-generate all .pb.go files, they will all be guaranteed to implement the new Message interface.

@johanbrandhorst
Copy link

What is the roadmap for this? Old generated versions of genproto is causing trouble for package maintainers who are trying to move to APIv2. Would be great with a timeline 😄.

gopherbot pushed a commit that referenced this issue May 14, 2020
This will make go-genproto messages make use of the new
protoreflect features and remove XXX fields. From my testing I
believe this should be safe. The subsequent regen PR/CL will need
some manual tweaks because of diffs in the mod files.

Updates: #1815
Change-Id: Ic9e0029c37bb7557245c68ef37dd1ddca37cbe66
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/56412
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Dietz <ndietz@google.com>
Reviewed-by: Chris Broadfoot <cbro@google.com>
Reviewed-by: Tyler Bui-Palsulich <tbp@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs Improvement to the documentation for an API.
Projects
None yet
Development

No branches or pull requests

5 participants