https://github.com/iamazeem/go-grpc-test
Go GRPC Test - sample DNS client and server apps
https://github.com/iamazeem/go-grpc-test
go golang grpc grpc-client grpc-go grpc-server
Last synced: about 2 months ago
JSON representation
Go GRPC Test - sample DNS client and server apps
- Host: GitHub
- URL: https://github.com/iamazeem/go-grpc-test
- Owner: iamazeem
- License: mit
- Created: 2023-05-27T06:29:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-19T12:15:37.000Z (about 2 years ago)
- Last Synced: 2024-12-16T08:34:50.522Z (over 1 year ago)
- Topics: go, golang, grpc, grpc-client, grpc-go, grpc-server
- Language: Go
- Homepage: https://github.com/iamazeem/go-grpc-test
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-grpc-test
[](https://github.com/iamazeem/go-grpc-test/actions/workflows/ci.yml)
Go [GRPC](https://grpc.io/) Test
- sample DNS client and server apps
See [dns/dns.proto](dns/dns.proto) for request and response.
## Overview Diagram
```mermaid
sequenceDiagram
autonumber
participant client
participant server
client->>server: request (domain)
activate server
note right of server: check domain in cache
server->>client: response (status, ip)
deactivate server
note left of client: use ip if status = RESOLVED
```
## Set up
- Install protocol buffers compiler (`protoc`)
- Install protocol buffers and GRPC plugins:
```shell
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
```
Update `GOPATH`:
```shell
export PATH="$PATH:$(go env GOPATH)/bin"
```
- Generate protocol buffers and GRPC files:
```shell
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
dns/dns.proto
```
Following files are generated:
- `dns/dns.pb.go`
- `dns_grpc.pb.go`
The generated files are already under `dns` directory.
## Build
```shell
go mod download
go build -o dns-server server/main.go
go build -o dns-client client/main.go
```
## Run
Run server in a separate terminal (as it blocks):
```shell
$ ./dns-server
staring DNS GRPC server on 0.0.0.0:9000
gRPC server started listening on 0.0.0.0:9000
```
Run client from a different terminal:
```shell
$ ./dns-client --domain "domain.xyz"
192.168.0.0
```
## License
[MIT](./LICENSE)