bigcommerce / gruf

gRPC Ruby Framework
https://github.com/bigcommerce/gruf
MIT License
626 stars 73 forks source link

Allow gruf to receive request objects in `call` #191

Closed dorner closed 11 months ago

dorner commented 12 months ago

What? Why?

Currently, gruf only supports hashes when sending messages - it won't allow you to actually pass in the request object itself. E.g. in client_spec.rb, this doesn't work:

    subject { client.call(method_name, req, metadata, opts) }

We'd really like to use the request object directly because we can make use of Sorbet generated types when we do this. We also can't just call to_h on the object and pass it in, because there are bugs in this method (such as this one).

Other Notables

It seems like this would be simple enough to implement by just checking to see if the passed in params respond to the to_proto message and if so, not to call the request_object method and just use it as is.

I can have a quick PR with this up if there are no objections.

splittingred commented 11 months ago

@dorner I think this is a reasonable request - and I agree generally with the approach.

Go for it on the PR - feel free to ping if you need assistance.

dorner commented 11 months ago

Thanks - here it is! #193 Let me know if I need to make any changes.