Giter VIP home page Giter VIP logo

grpc-go's Introduction

About

This project is a gRPC demonstration using Go.

It shows how we can create, get and list an entity called Category.

gRPC

gRPC is a Remote Procedure Call (RPC) framework developed by Google that makes the communication process between systems very smooth and fast using proto buffers and HTTP2.

It can be very useful in multiple scenarios, including microservices.

In the opposite of REST, gRPC supports bidirecional communication and streams, where we can send and receive data simultaneously.

Project technologies

Project structure

cmd - main package
internal
  | database - services responsible to interact with database
  | pb - auto-generated by protoc-gen-go-grpc lib
  | services - methods responsible to interact with proto, rpc and stream
proto - proto file
db.sqlite - in memory relational database

SQLite commands

A table Category must be created:

create table categories (id string, name string, description string);

Go Protocol Buffer Compiler

If you're using Windows and have Chocolatey as package manager, you can install Go Protocol Buffer Compiler using the command below

choco install protoc

Running app & gRPC interaction

You'll need to have two terminals opened.
One to run the project

go run .\cmd\grpcServer\main.go

And the other one to run Evans, the gRPC client

evans -r repl 
  • Inside Evans, you'll be able to see the list of calls available
  • Calling 'ListCategories'
  • Calling 'CreateCategoryStreamBidirectional'
    That's the gRPC magic!
    On this call, we'll be sending and receiving data simultaneously.

Useful commands

To initiate a project

go mod init projectName

To run the project

go run .\cmd\grpcServer\main.go

Command that synchronizes the go mod file with the actual dependencies used in the codebase

go mod tidy

Running SQLIte (it depends on SQLite is installed and configured on your OS). I used command below on Windows.

C:\sqlite\sqlite3.exe db.sqlite

This project was built and inspired during course on the Fullcycle platform.

grpc-go's People

Contributors

lucasdsalves avatar

Watchers

 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.