Skip to content

Ruby: use absolute module name for request/response namespaces#23765

Merged
stanley-cheung merged 3 commits intogrpc:masterfrom
HannahShiSFB:issue23672
Aug 14, 2020
Merged

Ruby: use absolute module name for request/response namespaces#23765
stanley-cheung merged 3 commits intogrpc:masterfrom
HannahShiSFB:issue23672

Conversation

@HannahShiSFB
Copy link
Copy Markdown
Collaborator

@HannahShiSFB HannahShiSFB commented Aug 7, 2020

Fixes #23672

@stanley-cheung stanley-cheung marked this pull request as draft August 7, 2020 17:11
@stanley-cheung stanley-cheung added lang/ruby release notes: yes Indicates if PR needs to be in release notes labels Aug 7, 2020
@stanley-cheung stanley-cheung self-assigned this Aug 7, 2020
@stanley-cheung
Copy link
Copy Markdown
Contributor

stanley-cheung commented Aug 7, 2020

[Edit: this comment is outdated.] I have a concern about this approach - this will change too much of the generated code and added these ::Google::Protobuf::DescriptorPool.generated_pool.lookup(<class>).msgclass calls to the runtime. I am hoping that we can fix the logic in the RubyTypeOf function to preserve the current generated code.

@stanley-cheung
Copy link
Copy Markdown
Contributor

stanley-cheung commented Aug 7, 2020

[Edit: this comment is outdated.] Looks like we should revert part of #23501 - in particular, we do need to pass the package parameter from PrintMethod() to RubyTypeOf. Inside RubyTypeOf, if the passed in object (the descriptor parameter) is in the same package as the package parameter (i.e. the package of the whole file itself), then we should remove the package part from descriptor->full_name() first, before the rest of the consideration with the optional ruby package name stuff.

So effectively, we need to add back these 3 lines https://github.com/grpc/grpc/pull/23501/files#diff-79b87df87999171e709bcdf2ea5a6d82L122-L124, I think.

@stanley-cheung stanley-cheung marked this pull request as ready for review August 12, 2020 18:08
@stanley-cheung
Copy link
Copy Markdown
Contributor

@HannahShiSFB Thanks for passing all the tests. I think there's one more final step: please run the ./pb/generate_proto_ruby.sh script from the src/ruby directory with your new grpc_ruby_plugin. This should re-generate a few .rb files that's being used by the tests. (My count is 8 more.) Please check those in and then we can re-run these PR one more time.

In order to run generate_proto_ruby.sh, you will first need to run these first:

$ ./tools/bazel build @com_google_protobuf//:protoc
$ ./tools/bazel build src/compiler:grpc_ruby_plugin

Thanks!

@stanley-cheung stanley-cheung changed the title Ruby: use protobuf descriptor pool to lookup ruby types Ruby: use absolute module name for request/response namespaces Aug 13, 2020
@apolcyn apolcyn self-assigned this Aug 14, 2020
@stanley-cheung
Copy link
Copy Markdown
Contributor

stanley-cheung commented Aug 14, 2020

@apolcyn Some notes for your review:

  • The main fix is to add this "." in front of the fully qualified proto message class name, so that it will be converted into an absolute path starting with :: as the Ruby package name. See this comment and this comment for the rationale for the fix. You may probably want to review the logic of this.

  • There are new tests added, and a test updated, in the PR.

  • Backport for v1.31.x is in Backport of #23765 to v1.31.x branch #23830. Backport for v1.30.x is in Backport of #23765 to v1.30.x branch #23831.

  • We also ran the src/ruby/pb/generate_proto_ruby.sh script to re-generate some generated files that will be updated by this protoc plugin change.

  • NOTE that, by running this generate_proto_ruby.sh script, 8 files were being updated in the master branch and the v1.31.x branch, while 6 files were being updated in the v1.30.x branch, likely due to some additional changes to the relevant .proto files after v1.30.

  • Updating the generated *_pb.rb files will benefit PHP & Ruby xds interop tests: add support for xds splitting and routing #23763, which is the PR to update the xDS tests according to the latest spec.

@stanley-cheung
Copy link
Copy Markdown
Contributor

All tests passed!

Copy link
Copy Markdown
Contributor

@apolcyn apolcyn left a comment

Choose a reason for hiding this comment

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

looks great!

@stanley-cheung stanley-cheung merged commit f873ad0 into grpc:master Aug 14, 2020
stanley-cheung added a commit that referenced this pull request Aug 14, 2020
srini100 added a commit that referenced this pull request Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/ruby release notes: yes Indicates if PR needs to be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ruby] module path names seems to be broken in >= v1.30.2

4 participants