Giter Site home page Giter Site logo

grpc-go-course's Introduction

golang-grpc

Go언어와 gRPC를 사용하며, gRPC [Golang] Master Class: Build Modern API & Microservices를 보면서 Go언어에서 gRPC를 사용하는 방법을 익힙니다.

Installation

gRPC

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin 
$ brew install protoc-gen-go
$ brew tap yoheimuta/protolint
$ brew install protolint
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

Generate gRPC

$ protoc -Igreet/proto --go_out=. --go_opt=module=github.com/dev-hyunsang/grpc-go-course --go-grpc_out=. --go-grpc_opt=module=github.com/dev-hyunsang/grpc-go-course greet/proto/dummy.proto

Using Evans

Installation

$ brew tap ktr0731/evans
$ brew install evans

Command in gRPC

> pacakge calculator
> show message
+---------------+
|    MESSAGE    |
+---------------+
| AvgRequest    |
| AvgResponse   |
| MaxRequest    |
| MaxResponse   |
| PrimeRequest  |
| PrimeResponse |
| SqrtRequest   |
| SqrtResponse  |
| SumRequest    |
| SumResponse   |
+---------------+
> show service
+-------------------+--------+--------------+---------------+
|      SERVICE      |  RPC   | REQUEST TYPE | RESPONSE TYPE |
+-------------------+--------+--------------+---------------+
| CalculatorService | Sum    | SumRequest   | SumResponse   |
| CalculatorService | Primes | PrimeRequest | PrimeResponse |
| CalculatorService | Avg    | AvgRequest   | AvgResponse   |
| CalculatorService | Max    | MaxRequest   | MaxResponse   |
| CalculatorService | Sqrt   | SqrtRequest  | SqrtResponse  |
+-------------------+--------+--------------+---------------+

> service CalculatorService
> call Sum
first_number (TYPE_INT32) => 1
second_number (TYPE_INT32) => 1
{
  "result": 2
}
> call Primes
number (TYPE_INT64) => 42
{
  "result": "2"
}
{
  "result": "3"
}
{
  "result": "7"
}

> call Avg
number (TYPE_INT32) => 1
number (TYPE_INT32) => 2
number (TYPE_INT32) => 3
number (TYPE_INT32) => 4
number (TYPE_INT32) => 5
number (TYPE_INT32) => 6
number (TYPE_INT32) => 7
number (TYPE_INT32) => 8
number (TYPE_INT32) => 9
number (TYPE_INT32) => 10
number (TYPE_INT32) => 
{
  "result": 5.5
}

참고한 글 및 문서

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.