Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 1 | gRPC in 3 minutes (Ruby) |
| 2 | ======================== |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 3 | |
Dan Ciruli | bc4b1ce | 2015-02-25 15:22:58 -0800 | [diff] [blame] | 4 | BACKGROUND |
| 5 | ------------- |
| 6 | For this sample, we've already generated the server and client stubs from [helloworld.proto](https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto). |
| 7 | |
Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 8 | PREREQUISITES |
| 9 | ------------- |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 10 | |
Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 11 | This requires Ruby 2.1, as the gRPC API surface uses keyword args. |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 12 | |
Tim Emiola | 5b5e146 | 2015-02-25 04:18:56 -0800 | [diff] [blame] | 13 | If you don't have that installed locally, you can use [RVM](https://www.rvm.io/) to use Ruby 2.1 for testing without upgrading the version of Ruby on your whole system. |
| 14 | ```sh |
| 15 | $ command curl -sSL https://rvm.io/mpapis.asc | gpg --import - |
| 16 | $ \curl -sSL https://get.rvm.io | bash -s stable --ruby=ruby-2.1 |
| 17 | $ |
| 18 | $ # follow the instructions to ensure that your're using the latest stable version of Ruby |
| 19 | $ # and that the rvm command is installed |
| 20 | ``` |
| 21 | - Make sure your run `source $HOME/.rvm/scripts/rvm` as instructed to complete the set up of RVM |
| 22 | |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 23 | INSTALL |
| 24 | ------- |
| 25 | |
| 26 | - Clone this repository. |
| 27 | - Follow the instructions in [INSTALL](https://github.com/grpc/grpc/blob/master/INSTALL) to install the gRPC C core. |
Yang Gao | cec80ed | 2015-02-24 23:45:00 -0800 | [diff] [blame] | 28 | - *Temporary* Install the full gRPC distribution from source on your local machine and update path: in [Gemfile](https://github.com/grpc/grpc-common/blob/master/ruby/Gemfile) to refer src/ruby within it. |
Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 29 | - this is necessary until the gRPC ruby gem is published |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 30 | - Use bundler to install |
| 31 | ```sh |
| 32 | $ # from this directory |
| 33 | $ gem install bundler && bundle install |
| 34 | ``` |
| 35 | |
Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 36 | Try it! |
| 37 | ------- |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 38 | |
| 39 | - Run the server |
| 40 | ```sh |
| 41 | $ # from this directory |
| 42 | $ bundle exec ./greeter_server.rb & |
| 43 | ``` |
| 44 | |
| 45 | - Run the client |
| 46 | ```sh |
| 47 | $ # from this directory |
| 48 | $ bundle exec ./greeter_client.rb |
| 49 | ``` |
Tim Emiola | c66fe1e | 2015-02-26 03:53:16 -0800 | [diff] [blame^] | 50 | |
| 51 | Tutorial |
| 52 | -------- |
| 53 | |
| 54 | You can find a more detailed tutorial in [gRPC Basics: Ruby](https://github.com/grpc/grpc-common/blob/master/ruby/route_guide/README.md) |