Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cvik/userd-go-grpc-demo
https://github.com/cvik/userd-go-grpc-demo
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cvik/userd-go-grpc-demo
- Owner: cvik
- Created: 2022-08-23T17:54:30.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-10T11:39:55.000Z (6 months ago)
- Last Synced: 2024-11-16T00:38:37.648Z (2 months ago)
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
### Userd - A simple demo service using gRPC in Go
#### Required Tooling
You need to install the protobuf compiler (`protoc`).
See https://grpc.io/docs/protoc-installation/ for instructions for your OS.Then install the Go plugins:
```bash
$ go install google.golang.org/protobuf/cmd/[email protected]
$ go install google.golang.org/grpc/cmd/[email protected]
```#### To Build
```bash
$ go generate ./... # Should do nothing since the generated code is checked in
$ go run cmd/server/main.go
```#### How to test
Install `grpcurl`:
```bash
$ go install github.com/fullstorydev/grpcurl/cmd/[email protected]`
```Then run the server in a separate shell `go run cmd/servermain.go`.
When the server is running we can call it with grpcurl like so:
```bash
$ grpcurl -plaintext -d '{"name": "Leffe", "Email": "[email protected]"}' localhost:1998 lendo.users.v1.Users/CreateUser
$ grpcurl -plaintext -d '{"id": "e7390ac4-cec8-4a54-bfc1-b3c322b61128"}' localhost:1998 lendo.users.v1.Users/GetUser
$ grpcurl -plaintext -d '{"id": "e7390ac4-cec8-4a54-bfc1-b3c322b61128"}' localhost:1998 lendo.users.v1.Users/DeleteUser
$ grpcurl -plaintext localhost:1998 lendo.users.v1.Users/ListUsers
```You can inspect what is supported by the service by using it's built-in reflection
capabilities:```bash
$ grpcurl -plaintext localhost:1998 list
$ grpcurl -plaintext localhost:1998 describe lendo.users.v1.Users
```You can describe individual RPCs and messages as well. See `grpcurl --help` for more info.