FindMaxNumber RPC Bi-Directional streaming client and server implemented using Go and GRPC with unit tests & integration tests.
go get github.com/cyyber/FindMaxNumberRPC
cd $GOPATH/src/github.com/cyyber/FindMaxNumberRPC
On successful build, binary files for server and client will be generated. Following is the command to build.
make build
Before starting server or client, certificates need to be generated for both server and clients and file paths of certificates must be configured in config/config.toml.
./server
./client
Server - GRPC server running supports only GetMaxNumber rpc call. GetMaxNumber takes number as input and responds only if it is max number. To start the server needs certificates as well as Root Certificate Authority file. All clients which tries to connect with this server, must provide the certificate signed by the same Root Certificate Authority as configured in server. In case of failure, client will not be allowed to establish connection.
Client - GRPC client takes infinite input until KeyboardInterrupt. All inputs are streamed to server and any response received by server gets printed on console.
Config
Field | Type | Server | Client |
---|---|---|---|
host | string | Address on which server will listen | Address where connection will be attempted |
port | int16 | Port on which server will listen | Port where connection will be attempted |
server_crt | string | File path for server.crt | N/A |
server_key | string | File path for server.key | N/A |
client_crt | string | N/A | File path for client.crt |
client_key | string | N/A | File path for client.key |
cert_auth | string | File path for CertificateAuthority.crt | File path for CertificateAuthority.crt |
Pre defined certificates has been generated for ip 127.0.0.1 and have been stored into pkg/server/test_data. These certificates are used for integration test only and in any case should not be used for production. These certificates has been generated by certstrap.
The following will only run unit tests.
go test -short -v ./...
The following will run unit tests as well as integration tests.
go test -v ./...