Giter Club home page Giter Club logo

ruby_node_grpc's Introduction

mailto:paulononaka@email.com CI


โœจ Ruby & Node with gRPC โœจ


Two microservices that communicates through gRPC that together displays a product list with custom discounts per user.

Project structure

client      // Client folder written in NodeJS
data        // Local storaged data in JSON
doc         // Architecture Decision Records
protos      // Protocol buffers
server      // Server folder written in Ruby

Requirements

This application relies on Docker.

Setup

docker-compose build

Running

docker-compose up

Server

A gRPC server made in Ruby (server folder).

The server service receives two RPC arguments and answers with the discount.

Server structure

server
โ”œโ”€โ”€ lib         // Serve service functions that connects to the gRPC Client
โ”‚   โ””โ”€โ”€ models  // Models that represents the local storaged data
โ”œโ”€โ”€ spec        // Rspec tests  

How to regenerate the protos

Install grpc-tools:

gem install grpc-tools

Then:

rake generate_proto

Client

A gRPC client made in Node (client folder).

The gRPC client consumes the gRPC server and exposes a HTTP endpoint GET /product.

Client structure

client
โ”œโ”€โ”€ src
โ”‚   โ””โ”€โ”€ api     // Espresso endpoints
โ”‚   โ””โ”€โ”€ repository  // Functions to returns the local storaged data
โ”‚   โ””โ”€โ”€ service     // Client services functions that connects to the gRPC Server 

Request samples

GET / - Health check

Ok!

GET /product?userId=1 - Returns a list of products and its discounts for a specific user.

[
  {
    id: "1",
    price_in_cents: 350,
    title: "Coca Cola",
    description: "It is nice to drink Coca",
    discount: {
      pct: 0,
      value_in_cents: 24
    }
  },
  {
    id: "2",
    price_in_cents: 2000,
    title: "Cake",
    description: "It is good to eat cake too",
    discount: {
      pct: 0,
      value_in_cents: 24
    }
  }
]

ruby_node_grpc's People

Contributors

paulononaka avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar James Cloos 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.