https://github.com/abstractmachines/grpc-go
Protobuf definitions and generated Golang client server code
https://github.com/abstractmachines/grpc-go
Last synced: 2 months ago
JSON representation
Protobuf definitions and generated Golang client server code
- Host: GitHub
- URL: https://github.com/abstractmachines/grpc-go
- Owner: abstractmachines
- Created: 2021-07-05T21:46:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-08T00:02:37.000Z (almost 4 years ago)
- Last Synced: 2025-02-06T02:57:24.353Z (4 months ago)
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# grpc-go
gRPC, protobufs, Go
## Runbook / Lightning Guide
```
make buildmake start-server
# in another terminal:
make start-client
```## References:
- [Google Developers Protobuf Tutorial] (https://developers.google.com/protocol-buffers/docs/gotutorial)
- [gRPC quickstart](https://grpc.io/docs/languages/go/quickstart/)
- [Ben Johnson on "Structuring a Go project with multiple binaries"](https://medium.com/@benbjohnson/structuring-applications-in-go-3b04be4ff091)## Working with Protobufs (high level)
1. Define data structures in a .proto file.
2. Compile that file to generate server methods and related client stubs for those same methods.
3. Profit.## Motivation
> Distributed Systems and Services
With gRPC, a client can "directly" call a method on a server, as if it were a local object. _The client has "stubs" of the server's methods._
This makes creating distributed applications and services a lot easier than thinking of clients and servers/services as having separate "methods."
> Performance
When we use the `protoc` compiler, that generates data access methods (getters, setters et al).
_The protobuf compiler encodes into an efficient binary format._
_The generated code takes care of the underlying details of reading/writing to/from services for us._
## Project structure and expected results
> Generating code with protoc compiler
1. Install protoc binaries for go and go grpc: `make build`
- Rather than using `$GOBIN` and `$GOPATH` for the binaries,
install them locally in the project root / module you're working in,
so that you can ensure that the versions being used are correct.> Expected result: you now have a new `/bin` dir in your project
> with the binaries `protoc-gen-go* protoc-gen-go-grpc*`2. Compile the protoc file, generating Go code: `make proto-gen`
> Expected result: You'll have a `*_grpc.pb.go` file and `*.pb.go` file### Go Modules go mod init
- See: blog.golang.org/using-go-modules- `go mod init github.com/abstractmachines/grpc-go/instruments`
- `go list -m all`