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

Support extensions for proto2 in Ruby? #6420

Closed
elad-maimon opened this issue Jul 20, 2019 · 5 comments
Closed

Support extensions for proto2 in Ruby? #6420

elad-maimon opened this issue Jul 20, 2019 · 5 comments
Assignees
Labels

Comments

@elad-maimon
Copy link

elad-maimon commented Jul 20, 2019

Hello,

I'm trying to compile proto2 file to Ruby (using "protoc --ruby_out=...") and get this error:
Extensions are not yet supported for proto2 .proto files.

I've found this issue that seems to be related but it's still open (from 2016).

Few questions:

  1. Are there any plans to support extensions for proto2 in Ruby?

  2. I'm not very familiar with protobuf, but I read that the challenge is to support it in the DSL. Assuming that I don't use these fields of the extensions, is it an option to support telling the compiler to skip it in the generated Ruby models but support encoding to bytes with those fields as empty?

  3. More than that, I'm actually only interested in encoding. Is there any way to encode Ruby hash to bytes based on proto definition without having the model in the middle? E.g, something like:

    encode_to_bytes('Proto.MyTestMessage', { field1: 42 })
    

    Instead of:

    msg = Proto::MyTestMessage.new(field1: 42)
    Proto::MyTestMessage.encode(msg)
    

    There's actually a JS tool called protobuf.js that generates a JSON descriptors file from proto file and allows exactly that, so if someone knows of a tool that can encode Ruby hashes to bytes based on JSON descriptors I'd love to hear.

Thanks!

@TeBoring
Copy link
Contributor

Sorry that we don't have time to add support for proto2 in ruby now. Is it possible for you to use proto3?

@TeBoring TeBoring self-assigned this Jul 23, 2019
@TeBoring TeBoring added the ruby label Jul 23, 2019
@elad-maimon
Copy link
Author

No, we have thousands of proto2 files in our company...

Any idea what can be done? Is some of the alternatives I suggested (bullets #2 and #3) viable?

Thanks!

@TeBoring
Copy link
Contributor

Sorry for the inconvenience.
For us, we do want to encourage users to use proto3 instead.
Proto3 provide all functions in proto2. Supporting both is an unnecessary burden to us.
Considering our resources, maybe two options are feasible:

  1. Migrate proto2 to proto3.
  2. Help us to implement proto2.
    BTW, proto2 is partially support for ruby. You can check if it's already enough for you.

@elad-maimon
Copy link
Author

elad-maimon commented Aug 1, 2019

Hi,

As I wrote above, my only problem is with extensions support in proto2 (this is the reason it fails).

Also, please note that also a n "ignore" option is OK for me since I don't really serialize the extended fields.

Is it still something hard to implement (mode that ignores extensions in proto2)?

Thanks!

@krak3n
Copy link

krak3n commented Jun 24, 2021

@TeBoring so the current recommendation for "constants" is to use extensions (see #3520). However since this isn't supported by ruby this results in an inconsistent language implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants