blob: e6ae90250a255c7ae66b347ce7a82e213ca09ab0 [file] [log] [blame] [view]
Jan Tattermuscha9b933e2015-10-30 15:52:191[![Gem](https://img.shields.io/gem/v/grpc.svg)](https://rubygems.org/gems/grpc/)
Tim Emiola9fe51782015-01-23 02:23:322gRPC Ruby
3=========
nnoble097ef9b2014-12-02 01:06:104
Tim Emiolac33efe42015-02-19 17:39:495A Ruby implementation of gRPC.
nnoble097ef9b2014-12-02 01:06:106
Tim Emiola50773e62015-06-03 17:19:217PREREQUISITES
8-------------
nnoble097ef9b2014-12-02 01:06:109
Chad Wilsonb238b492025-05-27 17:53:4010- Ruby 3.x. The gRPC API uses keyword args.
nnoble097ef9b2014-12-02 01:06:1011
Tim Emiola50773e62015-06-03 17:19:2112INSTALLATION
Tim Emiolac33efe42015-02-19 17:39:4913---------------
Stanley Cheunga79a8962015-08-19 17:43:2814
murgatroid99d8521e72016-01-15 18:12:2815**Linux and Mac OS X:**
Stanley Cheung1894f182015-08-19 23:32:3916
17```sh
18gem install grpc
19```
20
Brian Buchalter59179842021-04-19 21:31:2621If using a Gemfile and you wish to pull from a git repository or GitHub, make sure to tell bundler to retrieve submodules:
22```
23gem 'grpc', github: 'grpc/grpc', submodules: true
24```
25
Tim Emiola50773e62015-06-03 17:19:2126BUILD FROM SOURCE
27---------------------
28- Clone this repository
Tim Emiola9fe51782015-01-23 02:23:3229
Frank Natividad235a2e72017-12-14 09:48:5530- Init submodules
31
32```sh
33git submodule update --init
34```
35
Chad Wilsonb238b492025-05-27 17:53:4036- Install Ruby 3.x. Consider doing this with [RVM](http://rvm.io), it's a nice way of controlling
Tim Emiola9fe51782015-01-23 02:23:3237 the exact ruby version that's used.
Tim Emiolac33efe42015-02-19 17:39:4938```sh
nnoble0c475f02014-12-05 23:37:3939$ command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
Chad Wilsonb238b492025-05-27 17:53:4040$ \curl -sSL https://get.rvm.io | bash -s stable --ruby=ruby-3
nnoble097ef9b2014-12-02 01:06:1041$
nnoble0c475f02014-12-05 23:37:3942$ # follow the instructions to ensure that your're using the latest stable version of Ruby
43$ # and that the rvm command is installed
Tim Emiola0343f7f2015-01-26 20:04:4844```
Tim Emiola400ba762015-02-20 23:31:4245- Make sure your run `source $HOME/.rvm/scripts/rvm` as instructed to complete the set up of RVM
46
Tim Emiola9fe51782015-01-23 02:23:3247- Install [bundler](http://bundler.io/)
Tim Emiola0343f7f2015-01-26 20:04:4848```
Tim Emiola9fe51782015-01-23 02:23:3249$ gem install bundler
Tim Emiola0343f7f2015-01-26 20:04:4850```
nnoble097ef9b2014-12-02 01:06:1051
Tim Emiola50773e62015-06-03 17:19:2152- Finally, build and install the gRPC gem locally.
Tim Emiolac33efe42015-02-19 17:39:4953```sh
Tim Emiola5b071902015-02-20 23:35:2254$ # from this directory
Tim Emiolabd871622015-02-20 23:37:1755$ bundle install # creates the ruby bundle, including building the grpc extension
56$ rake # runs the unit tests, see rake -T for other options
Tim Emiola0343f7f2015-01-26 20:04:4857```
Tim Emiola9fe51782015-01-23 02:23:3258
Tim Emiola50773e62015-06-03 17:19:2159DOCUMENTATION
60-------------
61- rubydoc for the gRPC gem is available online at [rubydoc][].
62- the gRPC Ruby reference documentation is available online at [grpc.io][]
63
Tim Emiola9fe51782015-01-23 02:23:3264CONTENTS
65--------
Tim Emiola50773e62015-06-03 17:19:2166Directory structure is the layout for [ruby extensions][]
67- ext: the gRPC ruby extension
68- lib: the entrypoint gRPC ruby library to be used in a 'require' statement
69- spec: Rspec unittests
70- bin: example gRPC clients and servers, e.g,
Tim Emiola9fe51782015-01-23 02:23:3271
Tim Emiola50773e62015-06-03 17:19:2172 ```ruby
Teodore898ee62016-08-23 10:18:1673 stub = Math::Math::Stub.new('my.test.math.server.com:8080', :this_channel_is_insecure)
Tim Emiola50773e62015-06-03 17:19:2174 req = Math::DivArgs.new(dividend: 7, divisor: 3)
75 GRPC.logger.info("div(7/3): req=#{req.inspect}")
76 resp = stub.div(req)
77 GRPC.logger.info("Answer: #{resp.inspect}")
78 ```
murgatroid99d8521e72016-01-15 18:12:2879
Tim Emiola50773e62015-06-03 17:19:2180[ruby extensions]:http://guides.rubygems.org/gems-with-extensions/
81[rubydoc]: http://www.rubydoc.info/gems/grpc
Patrice Chalin4c4933e2020-06-16 12:40:5982[grpc.io]: https://grpc.io/docs/languages/ruby/quickstart
Stanley Cheung581846b2015-09-04 19:04:1783[Debian jessie-backports]:http://backports.debian.org/Instructions/