axellbrendow / full-cycle-2.0-gRPC

Files I produced during the gRPC classes of my microservices course.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

full-cycle-2.0-gRPC

Files I produced during the gRPC classes of my Microservices Full Cycle 3.0 course.

Protocol Buffers

Language Guide: https://developers.google.com/protocol-buffers/docs/proto3

To compile .proto files, install it's compiler:

sudo apt install -y protobuf-compiler

As this example is in the Go language, install it and then install protoc-gen-go-grpc:

go get google.golang.org/protobuf/cmd/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc

Make sure your go binaries are in your PATH variable. In my case they are at $HOME/go/bin.

To generate the Golang code for gRPC communication run:

protoc --proto_path=proto proto/*.proto --go_out=pb --go-grpc_out=pb

Running the server

go run cmd/server/server.go

evans gRPC Client

Get the binary release from the evans repo: https://github.com/ktr0731/evans/releases and put it in your binaries folder. Ex.: /usr/bin

Now, run:

evans -r repl --host localhost --port 50051

Inside the evans console, run:

service UserService  # Set the service we will use
call AddUser  # Calls the AddUser function from UserService

# Then enter the values of the Id (server will ignore), Name and Email

My own gRPC Client in Go

To test it, run:

go run cmd/client/client.go

My own gRPC Client in Go receiving the server stream

To test it, run:

go run cmd/client/client_receiving_stream.go

My own gRPC Client in Go sending data through a stream

To test it, run:

go run cmd/client/client_sending_stream.go

My own gRPC Client and Server using a bidirectional stream

To test it, run:

go run cmd/client/client_bidirectional_stream.go

Inserting multiple users through the same connection and stream:

Video showing client and server running

About

Files I produced during the gRPC classes of my microservices course.


Languages

Language:Go 100.0%