grpc-demo/README.md

29 lines
1003 B
Markdown

# gRPC - demo
## How to run it locally?
**Prerequisites**:
- Go 1.19+
- [protoc](https://grpc.io/docs/protoc-installation/)
- Go plugins for the protocol compiler:
- ``go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0``
- ``go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0``
1. Clone this repo.
2. ``cd ./grpc-demo``
3. Run ``go generate ./...``.
4. Compile and execute the server code - ``go run ./cmd/server/main.go``.
5. From a different terminal, compile and execute the client code - ``go run ./cmd/client/main.go -example unary``.
### Client - available examples
1. **unary** - example of the simplest type of RPC where the client sends a single request and gets back a single
response. It's the default one.
2. **server** - example of server streaming RPC.
3. **client** - example of client streaming RPC.
4. **bidirectional** - example of bidirectional streaming RPC.
5. **james** - SayHelloToJames without error
6. **jameserror** - error handling