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 | 5b5e146 | 2015-02-25 04:18:56 -0800 | [diff] [blame] | 12 | 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. |
Tim Emiola | 8af5175 | 2015-02-26 02:04:15 -0800 | [diff] [blame^] | 13 | RVM is also useful if you don't have the necessary privileges to update your system's Ruby. |
Tim Emiola | 5b5e146 | 2015-02-25 04:18:56 -0800 | [diff] [blame] | 14 | ```sh |
Tim Emiola | 8af5175 | 2015-02-26 02:04:15 -0800 | [diff] [blame^] | 15 | $ # RVM installation as specified at https://rvm.io/rvm/install |
| 16 | $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 |
Tim Emiola | 5b5e146 | 2015-02-25 04:18:56 -0800 | [diff] [blame] | 17 | $ \curl -sSL https://get.rvm.io | bash -s stable --ruby=ruby-2.1 |
| 18 | $ |
| 19 | $ # follow the instructions to ensure that your're using the latest stable version of Ruby |
| 20 | $ # and that the rvm command is installed |
| 21 | ``` |
Tim Emiola | 8af5175 | 2015-02-26 02:04:15 -0800 | [diff] [blame^] | 22 | - *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] | 23 | |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 24 | INSTALL |
| 25 | ------- |
| 26 | |
| 27 | - Clone this repository. |
| 28 | - Follow the instructions in [INSTALL](https://github.com/grpc/grpc/blob/master/INSTALL) to install the gRPC C core. |
Tim Emiola | 8efcb53 | 2015-02-26 01:50:44 -0800 | [diff] [blame] | 29 | - *Temporary* |
| 30 | - Install the full gRPC distribution from source on your local machine |
| 31 | - Build gRPC Ruby as described in [installing from source](https://github.com/grpc/grpc/blob/master/src/ruby/README.md#installing-from-source) |
Tim Emiola | 8af5175 | 2015-02-26 02:04:15 -0800 | [diff] [blame^] | 32 | - update `path:` in [Gemfile](https://github.com/grpc/grpc-common/blob/master/ruby/Gemfile) to refer to src/ruby within the gRPC directory |
| 33 | - N.B: these steps are necessary until the gRPC ruby gem is published |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 34 | - Use bundler to install |
| 35 | ```sh |
| 36 | $ # from this directory |
| 37 | $ gem install bundler && bundle install |
| 38 | ``` |
| 39 | |
Tim Emiola | eb158ff | 2015-02-21 06:29:53 -0800 | [diff] [blame] | 40 | Try it! |
| 41 | ------- |
Tim Emiola | 49f3ccd | 2015-02-19 11:09:19 -0800 | [diff] [blame] | 42 | |
| 43 | - Run the server |
| 44 | ```sh |
| 45 | $ # from this directory |
| 46 | $ bundle exec ./greeter_server.rb & |
| 47 | ``` |
| 48 | |
| 49 | - Run the client |
| 50 | ```sh |
| 51 | $ # from this directory |
| 52 | $ bundle exec ./greeter_client.rb |
| 53 | ``` |