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 | ------------- |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 6 | For this sample, we've already generated the server and client stubs from [helloworld.proto][] |
Dan Ciruli | bc4b1ce | 2015-02-25 15:22:58 -0800 | [diff] [blame] | 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 | 9da96d9 | 2015-04-30 13:09:07 -0400 | [diff] [blame] | 11 | - Ruby 2.x |
Tim Emiola | 9da96d9 | 2015-04-30 13:09:07 -0400 | [diff] [blame] | 12 | This requires Ruby 2.x, as the gRPC API surface uses keyword args. |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 13 | If you don't have that installed locally, you can use [RVM][] to use Ruby 2.x for testing without upgrading the version of Ruby on your whole system. |
Tim Emiola | 8af5175 | 2015-02-26 02:04:15 -0800 | [diff] [blame] | 14 | RVM is also useful if you don't have the necessary privileges to update your system's Ruby. |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 15 | |
| 16 | ```sh |
| 17 | $ # RVM installation as specified at https://rvm.io/rvm/install |
| 18 | $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 |
| 19 | $ \curl -sSL https://get.rvm.io | bash -s stable --ruby=ruby-2 |
| 20 | $ |
| 21 | $ # follow the instructions to ensure that your're using the latest stable version of Ruby |
| 22 | $ # and that the rvm command is installed |
| 23 | ``` |
Tim Emiola | 8af5175 | 2015-02-26 02:04:15 -0800 | [diff] [blame] | 24 | - *N.B* Make sure your run `source $HOME/.rvm/scripts/rvm` as instructed to complete the set-up of RVM. |
Tim Emiola | 5b5e146 | 2015-02-25 04:18:56 -0800 | [diff] [blame] | 25 | |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 26 | INSTALL |
| 27 | ------- |
| 28 | |
Tim Emiola | 9da96d9 | 2015-04-30 13:09:07 -0400 | [diff] [blame] | 29 | - Clone this repository |
Tim Emiola | 5828df6 | 2015-02-26 12:57:10 -0800 | [diff] [blame] | 30 | - Use bundler to install the example package's dependencies |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 31 | |
| 32 | ```sh |
| 33 | $ # from this directory |
| 34 | $ gem install bundler # if you don't already have bundler available |
| 35 | $ bundle install |
| 36 | ``` |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 37 | |
Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 38 | Try it! |
| 39 | ------- |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 40 | |
| 41 | - Run the server |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 42 | |
| 43 | ```sh |
| 44 | $ # from this directory |
| 45 | $ bundle exec ./greeter_server.rb & |
| 46 | ``` |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 47 | |
| 48 | - Run the client |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 49 | |
| 50 | ```sh |
| 51 | $ # from this directory |
| 52 | $ bundle exec ./greeter_client.rb |
| 53 | ``` |
Tim Emiola | c66fe1e | 2015-02-26 03:53:16 -0800 | [diff] [blame] | 54 | |
| 55 | Tutorial |
| 56 | -------- |
| 57 | |
| 58 | You can find a more detailed tutorial in [gRPC Basics: Ruby](https://github.com/grpc/grpc-common/blob/master/ruby/route_guide/README.md) |
Tim Emiola | 9da96d9 | 2015-04-30 13:09:07 -0400 | [diff] [blame] | 59 | |
Tim Emiola | e69e13d | 2015-06-03 11:56:34 -0700 | [diff] [blame^] | 60 | [helloworld.proto]:https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto |
| 61 | [RVM]:https://www.rvm.io/ |