Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhufuyi/grpc_examples
Rich examples of grpc usage, helps you learn and use grpc more easily.
https://github.com/zhufuyi/grpc_examples
Last synced: about 1 month ago
JSON representation
Rich examples of grpc usage, helps you learn and use grpc more easily.
- Host: GitHub
- URL: https://github.com/zhufuyi/grpc_examples
- Owner: zhufuyi
- License: mit
- Created: 2022-05-21T07:44:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-08T14:38:54.000Z (8 months ago)
- Last Synced: 2024-06-22T15:46:24.056Z (6 months ago)
- Language: Go
- Homepage:
- Size: 9.63 MB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: security/jwt_token/README.md
Awesome Lists containing this project
README
## English | [简体中文](readme-cn.md)
### Description
This is a collection of commonly used gRPC knowledge points, perfect for comprehensive learning and usage of gRPC. These gRPC knowledge points are extracted from the Go development framework sponge.
**Sponge** is a powerful development framework that integrates `automatic code generation`, `gin` and `gRPC` frameworks. It greatly improves development efficiency and reduces development difficulty by providing one-stop project development from code generation, development, testing, API documentation to deployment, realizing "low-code" development projects.
Sponge Repo: [https://github.com/zhufuyi/sponge](https://github.com/zhufuyi/sponge)
### Quick Start
#### Go Configuration
This step can be skipped if go has already been set up.
```bash
# Linux or MacOS
export GOROOT="/opt/go" # your go installation directory
export GOPATH=$HOME/go # Set the directory where the "go get" command downloads third-party packages
export GOBIN=$GOPATH/bin # Set the directory where the executable binaries are compiled by the "go install" command.
export PATH=$PATH:$GOBIN:$GOROOT/bin # Add the $GOBIN directory to the system path.# Windows
setx GOPATH "D:\your-directory" # Set the directory where the "go get" command downloads third-party packages
setx GOBIN "D:\your-directory\bin" # Set the directory where the executable binary files generated by the "go install" command are stored.
```
#### Installation of Protoc and Plugins
1. Copy the protobuf file dependency folder [include](include) to the `$GOBIN` directory.
2. Download protoc from: [https://github.com/protocolbuffers/protobuf/releases/tag/v25.2](https://github.com/protocolbuffers/protobuf/releases/tag/v25.2)
> Download the protoc binaries according to the system type, move the protoc binaries to `$GOBIN`.
3. Install Protoc Plugins
```bash
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
go install github.com/envoyproxy/protoc-gen-validate@latest
go install github.com/mohuishou/protoc-gen-go-gin@latest
go install github.com/srikrsna/protoc-gen-gotag@latest
```
### List of examples
- [Serialization and deserialization of protobuf](https://github.com/zhufuyi/grpc_examples/tree/main/protobuf)
- [4 ways of calling in helloworld demo](https://github.com/zhufuyi/grpc_examples/tree/main/helloworld)
- [interceptor](https://github.com/zhufuyi/grpc_examples/tree/main/interceptor)
- [recovery](https://github.com/zhufuyi/grpc_examples/tree/main/recovery)
- [logging](https://github.com/zhufuyi/grpc_examples/tree/main/logging)
- [keepalive](https://github.com/zhufuyi/grpc_examples/tree/main/keepalive)
- [metadata set and read](https://github.com/zhufuyi/grpc_examples/tree/main/metadata)
- [timeout](https://github.com/zhufuyi/grpc_examples/tree/main/timeout)
- [swagger](https://github.com/zhufuyi/grpc_examples/tree/main/swagger/example)
- [tag](https://github.com/zhufuyi/grpc_examples/tree/main/tag)
- [validate](https://github.com/zhufuyi/grpc_examples/tree/main/validate)
- [wait for ready](https://github.com/zhufuyi/grpc_examples/tree/main/waitForReady)
- [http to grpc](https://github.com/zhufuyi/grpc_examples/tree/main/httpToGrpc)
- [call grpc in gin](https://github.com/zhufuyi/grpc_examples/tree/main/httpToGrpc/ginToGrpc)
- [grpc gateway](https://github.com/zhufuyi/grpc_examples/tree/main/httpToGrpc/grpc-gateway)
- [security](https://github.com/zhufuyi/grpc_examples/tree/main/security)
- [TLS server-side authentication and two-way authentication](https://github.com/zhufuyi/grpc_examples/tree/main/security/tls)
- [kv token authentication](https://github.com/zhufuyi/grpc_examples/tree/main/security/kv_token)
- [jwt token authentication](https://github.com/zhufuyi/grpc_examples/tree/main/security/jwt_token)
- [register and discovery](https://github.com/zhufuyi/grpc_examples/tree/main/registerDiscovery)
- [consul](https://github.com/zhufuyi/grpc_examples/tree/main/registerDiscovery/consul)
- [etcd](https://github.com/zhufuyi/grpc_examples/tree/main/registerDiscovery/etcd)
- [nacos](https://github.com/zhufuyi/grpc_examples/tree/main/registerDiscovery/nacos)
- [load-balance](https://github.com/zhufuyi/grpc_examples/tree/main/loadbalance)
- [ip loadbalance](https://github.com/zhufuyi/grpc_examples/tree/main/loadbalance/ipAddr)
- [consul_loadbalance](https://github.com/zhufuyi/grpc_examples/tree/main/loadbalance/consul)
- [etcd_loadbalance](https://github.com/zhufuyi/grpc_examples/tree/main/loadbalance/etcd)
- [nacos_loadbalance](https://github.com/zhufuyi/grpc_examples/tree/main/loadbalance/nacos)
- [ratelimit](https://github.com/zhufuyi/grpc_examples/tree/main/ratelimit)
- [breaker](https://github.com/zhufuyi/grpc_examples/tree/main/breaker)
- [retry](https://github.com/zhufuyi/grpc_examples/tree/main/retry)
- [metrics](https://github.com/zhufuyi/grpc_examples/tree/main/metrics)
- [default grpc metrics](https://github.com/zhufuyi/grpc_examples/tree/main/metrics/defaultMetrics)
- [customized grpc metrics](https://github.com/zhufuyi/grpc_examples/tree/main/metrics/customMetrics)
- [tracing](https://github.com/zhufuyi/grpc_examples/tree/main/tracing)
- [http-->grpc tracing](https://github.com/zhufuyi/grpc_examples/tree/main/tracing/http2rpc)
- [grpc-->grpc tracing](https://github.com/zhufuyi/grpc_examples/tree/main/tracing/rpc2rpc)
- [practical project use](https://github.com/zhufuyi/grpc_examples/tree/main/usage)