GithubHelp home page GithubHelp logo

grpc's Introduction

gRPC

Example of gRPC with Go

Compiling .proto files:


--go_out specifies out directory for generation all entities "messages of .proto file"

--go-grpc_out specifies out directory for generation all gRPC code "services of .proto file"

latest param specifies directory for get .proto file

protoc --go_out=. --go-grpc_out=. proto/course_category.proto

Installing client gRPC:


The client used for tests is named evans

# MacOS installation using brew
brew tap ktr0731/evans
brew install evans

Creating SQLite database:


# For connect on database
sqlite3 db.sqlite
-- For create table categories
create table categories(
    id string primary key,
    name string,
    description string
);

-- For create table courses
create table courses(
    id string primary key,
    name string,
    description string,
    category_id string,
    foreign key (category_id) references categories(id)
);

Running server:


go run cmd/grpcServer/main.go

Running client:


By default the evans client listens on TCP port 50051, you don't need to specify if you are using this port

evans -r repl

Select gRPC service on client:


Needs to start client before selecting gRPC service

first param is the gRPC service name

# If your function uses stream mode, for stop this use 'Ctrl + D'
service CategoryService

Calling gRPC service function on client:


Needs to start client before selecting gRPC service

first param is the function name

call CreateCategory

grpc's People

Contributors

jonathanmdr avatar

Stargazers

 avatar

Watchers

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