add README.md

This commit is contained in:
Dawid Wysokiński 2023-05-07 07:22:24 +02:00
parent c2769a233e
commit a74432871d
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
2 changed files with 30 additions and 0 deletions

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# gRPC - demo
## How to run it locally?
**Prerequisites**:
- Go 1.20+
- [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

View File

@ -95,6 +95,8 @@ func TestServer_SayHelloBidirectionalStream(t *testing.T) {
}
func newServer(t *testing.T) proto.GreeterClient {
t.Helper()
buffer := 101024 * 1024
lis := bufconn.Listen(buffer)