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

Stub structure and Methods will relay on protobuf API V2 #595

Open
avivbaron opened this issue Feb 6, 2024 · 13 comments
Open

Stub structure and Methods will relay on protobuf API V2 #595

avivbaron opened this issue Feb 6, 2024 · 13 comments

Comments

@avivbaron
Copy link

Hey, since the old protobuf package of google is already deprecated, I was trying to base my code only on the new package(google.golang.org/protobuf) and everything looks fine but since Im using and relaying on your Stub structre and methods which relay on the old package I'm a bit stuck with finding how to replace it appropriately.

Do you have any suggestions on how to replace it correctly or maybe you already working on adapting it to V2 ? :)

Thanks

@jhump
Copy link
Owner

jhump commented Feb 6, 2024

Do you have any suggestions on how to replace it correctly or maybe you already working on adapting it to V2 ? :)

The README has a blurb at the top talking about this. I am working on a v2, and it's nearly done (https://github.com/jhump/protoreflect/tree/v2).

But, also, as of v1.15, interop between this repo and the protobuf API v2 should work fine. So it should be easy to continue using this repo and also use the new protobuf API v1 support for reflection, descriptors, and dynamic messages.

@avivbaron
Copy link
Author

Do you have any suggestions on how to replace it correctly or maybe you already working on adapting it to V2 ? :)

The README has a blurb at the top talking about this. I am working on a v2, and it's nearly done (https://github.com/jhump/protoreflect/tree/v2).

But, also, as of v1.15, interop between this repo and the protobuf API v2 should work fine. So it should be easy to continue using this repo and also use the new protobuf API v1 support for reflection, descriptors, and dynamic messages.

I have an issue with the conversion between V1 message and V2. but i'll try to find a way to fix it.
Do you have an estimate of when the new version will be released?

Thanks :)

@jhump
Copy link
Owner

jhump commented Feb 7, 2024

Do you have an estimate of when the new version will be released?

I had hoped to cut an initial release candidate in 2023 😞

I think the repo is really close. There may be some recent-ish changes on the main branch that I need to cherry-pick or port to the v2 branch, but the functionality and the API and main code I think are all pretty much done. But it needs more test coverage (and inevitably fixes for whatever the new tests uncover). I would like to get it done soon.

@avivbaron
Copy link
Author

Hi,
Thank you for your detailed answer.
Any chance you will be able to provide a kind of early access?
Would be very helpful for both of us.
I can provide some input about what working and what is not.
Thanks

@jhump
Copy link
Owner

jhump commented Feb 8, 2024

@avivbaron, sure, you can already try it out. There have been no tagged releases on that work-in-progress branch, so you have to pull it in using a commit sha. This would pull in the current head of that branch:

go get github.com/jhump/protoreflect/v2@c9ae7caed596cda2e3c4a90f5973a46081a371a

The package structure is a little different. There is no longer any desc, dynamic, or desc/protoparse at all. (The former two are replaced by functionality in the protobuf API v2; the latter replaced by github.com/bufbuild/protocompile.) All of the other functionality is still present, but moved around a little. For example, desc/protoprint and desc/builder are now protoprint and protobuilder. And dynamic/msgregistry functionality is now a part of the new protoresolve package.

@avivbaron
Copy link
Author

Thank you very much :)

@avivbaron
Copy link
Author

Hey, I'm using the protoparse.Parser function in my project and I saw that there isn't parser package or function in your new version. can you help me with replacing it correctly?

Thanks :)

@jhump
Copy link
Owner

jhump commented Feb 20, 2024

@avivbaron, see https://github.com/bufbuild/protocompile?tab=readme-ov-file#migrating-from-protoparse

@avivbaron
Copy link
Author

Thanks again for helping me a lot :)
After I did those changes I left with "*descriptorpb.FileDescriptorProto" object. How do I get "protoreflect.FileDescriptor" from it?

@jhump
Copy link
Owner

jhump commented Feb 21, 2024

@avivbaron, sorry, I don't have enough context. What exactly are you doing? Most of the protocompile API is in terms of protoreflect.Descriptor.

@avivbaron
Copy link
Author

avivbaron commented Feb 22, 2024

U r right. it was my mistake.
The last thing I got left to do is to find out how to fill "dependencies" in linker.Link() while the result object the i get from "parser.ResultFromAST()", result.FileDescriptorProto().Dependency returns []string instead of []linker.Files

@jhump
Copy link
Owner

jhump commented Feb 22, 2024

@avivbaron, why are you calling the linker directly? What is it you are doing that prevents you from using the main protocompile.Compiler? The root compiler package handles all of the steps. The sub-packages are only meant to be used if you are doing something custom, such as parsing without linking.

@avivbaron
Copy link
Author

Thanks a lot! I'm done with the migration to the new protobuf modules all thanks to you :)

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

No branches or pull requests

2 participants