Giter Site home page Giter Site logo

aelgees / ruby-grpc-example Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 20 KB

A Ruby GRPC example repository is a project that demonstrates how to use the GRPC (gRPC Remote Procedure Calls) framework with the Ruby programming language (Ruby on Rails).)

Dockerfile 0.73% Makefile 0.89% Ruby 97.86% Shell 0.52%

ruby-grpc-example's Introduction

Ruby on Rails gRPC Example

This is an example Ruby on Rails application that demonstrates how to use gRPC in a Rails project.

Prerequisites

  • Docker 20 or higher
  • Docker Compose 1.29 or higher
  • Ruby 3.1.2 or higher
  • Rails 7.0.3 or higher
  • The bundler gem (run gem install bundler to install)
  • The grpc gem (run gem install grpc to install)
  • The grpc-tools gem (run gem install grpc-tools to install)

Setup

  1. Clone the repository: git clone https://github.com/aelgees/ruby-grpc-example.git
  2. Navigate to the project directory: cd ruby-grpc-example
  3. Generate .proto file with run ./generate_proto.sh This will generate two files in the lib directory on client and server: books_pb.rb and books_services_pb.rb. The first file contains the message definitions for your .proto file, and the second file contains the gRPC service definitions.

How to run

First create network, run the following command:

make create-network

To start the Rails server and client, run the following command:

make start

To stop the Rails server and client, run the following command:

make stop

Information

Here is a description of the two endpoints in the API you provided:

localhost:8002/books - This endpoint returns a list of books in the form of a JSON object with a "data" field. The "data" field is an array of objects, each representing a book with the following fields:

  • "id": a unique identifier for the book
  • "title": the title of the book
  • "description": a brief description of the book
  • "tags": an array of tags associated with the book
  • "price": the price of the book

localhost:8002/books/:id - This endpoint returns a single book in the form of a JSON object with a "data" field. The "data" field is an object representing a book with the same fields as described for the localhost:8002/books endpoint. The :id parameter in the endpoint specifies the unique identifier of the book you want to retrieve.

For example, if you make a GET request to localhost:8002/books/1001, the API will return the book with the id 1001.

ruby-grpc-example's People

Stargazers

Dang Hoang Hung avatar

Watchers

Adam Lesmana Ganda Saputra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.