GithubHelp home page GithubHelp logo

grpc-service's Introduction

GRPC Microservice Demo

This is an example service to get comfortable with building a microservice based on the gRPC protocol and Protocol Buffers.

Background

As an alternative to the common JSON format, Protocol Buffers are a condensed data format which support gRPC calls. Compared to REST(ful) APIs which uses HTTP 1.1, the gRPC protocol utilizes faster and safer HTTP 2 calls. While REST APIs provide CRUD (Create, Retrieve, Update, Delete) processes, gRPC is asynchronous and more flexible by providing four different options of streaming data. In general, it is possible to make unary gRPC calls, server side streaming, client side streaming and bidirectional streaming.

Compling

The compilation of Protocol Buffers can be conducted statically by pre-processing or dynamically by loading and parsing the .proto file at runtime.

protoc -I=. ./proto/weather.proto \
  --js_out=import_style=commonjs,binary:./server \
  --grpc_out=./server \
  --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin`

While the statical compilation is executed as above, the dynamic conversion requires some additional setup and a package that can be installed with npm install @grpc/proto-loader.

HowTo

  • Install Dependencies with npm install.
  • Compile Proto file by npm run proto.
  • Generate SSL Certificates for encrypted communication by npm run gen:certs.
  • Start server by npm run server.
  • Start client by npm run client.

Helpful Resources & Acknowledgements

grpc-service's People

Contributors

lukaschoebel avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

grpc-service's Issues

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.