Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use gRPC in an existing Rails application

The current web app setup is like this: there is a central server which interacts with different services through http API calls using JSON as the response object. We want to switch to using gRPC for the communication between these services to improve performance. So, can anyone help how can I use gRPC gem in my Rails application and services without changing the existing MCV ( model, controller, view) code structure.

like image 978
Vinay Lodha Avatar asked Nov 17 '16 10:11

Vinay Lodha


1 Answers

gruf can help:

gruf is a Ruby framework that wraps the gRPC Ruby library to provide a more streamlined integration into Ruby and Ruby on Rails applications.

There's also a demo Rails application that can be used as a reference.

After creating your proto file, generating the Ruby wrappers and wiring it up to your Rails application, you can simply bundle exec gruf to launch a gRPC server.

like image 95
Ates Goral Avatar answered Sep 17 '22 15:09

Ates Goral