protoc -Igreet/proto --go_out=. --go_opt=module=github.com/MartinLupa/gRPC --go-grpc_out=. --go-grpc_opt=module=github.com/MartinLupa/gRPC greet/proto/dummy.proto
Explanation of command flags:
-
-Igreet/proto
: -I/ indicates where the input file is. -
--go_out=.
and--go-grpc_out=.
: indicate that we want to generate the code in the current directory. But will be influenced by--go_opt
and--go-grpc_opt
. -
--go_opt=module=github.com/MartinLupa/gRPC
and--go-grpc_opt=module=github.com/MartinLupa/gRPC
: we are indicating that our module is called "github.com/MartinLupa/gRPC", so the command will remove this part of the string from the go_package(originally "github.com/MartinLupa/gRPC/greet/proto") and will leave only "./greet/proto", so the output of the command will be available in such path of ./greet/proto. -
greet/proto/dummy.proto
: indicates where the .proto file is located.
make <project_name>
: to generate the code out of the .proto file.make help
: to see all available options.
- open one terminal and run
./bin/<project_name>/server
- open a second terminal and run
./bin/<project_name>/client
Check the README.md file inside each project to learn how to use it.
Simple greeting and calculator gRPC Unary API.
calculator: gRPC Unary README.md
The GreetService and CalculatorService are modified by adding function calls that support streams on the server.
The GreetService and CalculatorService are modified by adding function calls that support streams on the client.
The GreetService and CalculatorService are modified by adding function calls that support streams on the client.
- GreetWithDeadline: includes waiting timeouts for responses.
- Greet server/client: SSL Security.
- Reflection & Evans CLI: to visualize services and endpoints.
- Install evans CLI from https://github.com/ktr0731/evans
evans --host localhost --port 50051 --reflection repl
show package
show message
package calculator & show service
call Sum (testing Sum endpoint)