-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Added ruby wrapper for grpc_compression_options #7216
Added ruby wrapper for grpc_compression_options #7216
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
9666f93
to
b95b428
Compare
CLAs look good, thanks! |
Why are the |
My main idea with that was just so that I could test them with rspec. I defined all of the internal C functions as private methods on the ruby Was also thinking it would make it easy to make them public though too in case we wanted to. On Fri, Jul 1, 2016 at 3:49 PM, Michael Lumish notifications@github.com
|
I think you should not have tests for private methods. They are, by definition, implementation details of the class, and they should not be required to be stable. The units that you test should be your public interface, and most of those functions appear to be true helper methods that wouldn't be useful to a Ruby user. |
&grpc_rb_compression_options_data_type, wrapper); | ||
|
||
/* Take both string and symbol parameters */ | ||
ruby_str = rb_funcall(new_level, rb_intern("to_s"), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense for this function to accept only symbol parameters. We are dealing with a predefined set of values that are unlikely to change in the foreseeable future, and symbols work well in that case. Plus, if you do it that way, you can predefine the symbols and compare against them directly, instead of doing string comparisons.
c7c4769
to
ab9bdf5
Compare
ab9bdf5
to
b72cc3d
Compare
|
||
/* Ruby symbols for the names of the different compression levels. */ | ||
rb_define_const(grpc_rb_cCompressionOptions, "COMPRESS_NONE_SYM", | ||
ID2SYM(rb_intern("none"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need constants that hold symbols. The symbol itself should be a suitable constant for referring to a level. And if you get rid of the constants, you can just store the ID directly, like in the channel code (https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/rb_channel.c#L377).
|
||
rb_raise(rb_eArgError, | ||
"Unrecognized compression level name." | ||
"Valid compression level names are none, low, medium, and high."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you still need a return statement here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add it still, but I saw this compile on OSX and linux.
I think it's building here, but certain interop tests that should be unaffected seem to be failing right now.
Actually, I noticed that you have |
The latest updates remove testing of non-API methods and shrink the API too. The tests still use compression algorithm names like gzip and deflate, but should no longer test for internal enum values. |
LGTM |
test this please |
1 similar comment
test this please |
This adds a ruby class wraps a grpc_compression_options. The ruby wrapper has optional constructor args but is immutable.
Right now, it could be added to the ruby server_args or channel_args hashes with #merge, for example.
It's #to_hash and #to_channel_args_hash methods return compression-related key-values that can be passed to the core.