Files I produced during the gRPC classes of my Microservices Full Cycle 3.0 course.
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
go run cmd/server/server.go
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
To test it, run:
go run cmd/client/client.go
To test it, run:
go run cmd/client/client_receiving_stream.go
To test it, run:
go run cmd/client/client_sending_stream.go
To test it, run:
go run cmd/client/client_bidirectional_stream.go
Inserting multiple users through the same connection and stream: