https://github.com/francistm/grpc-redis-client-lb
Golang grpc redis based client load balance
https://github.com/francistm/grpc-redis-client-lb
discovery-service golang grpc redis
Last synced: 6 months ago
JSON representation
Golang grpc redis based client load balance
- Host: GitHub
- URL: https://github.com/francistm/grpc-redis-client-lb
- Owner: francistm
- Created: 2022-03-27T07:59:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-17T11:18:27.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T16:51:09.478Z (6 months ago)
- Topics: discovery-service, golang, grpc, redis
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GRPC Redis Client LoadBalancer
## Redis connection
There's no restriction for redis package.You can create a struct which wrap the redis package you're using, and implement the `resolver.Redis` interface.
## Discovery``` golang
// create an redis connection which implements the resolver.Redis interface
var redisConn resolver.Redis// registe schema
discovery.RegisterSchema(redisConn)// discovery and dial the server
conn, err := grpc.Dial("redis://service-foo", grpc.WithInsecure())
```## Registry
``` golang
// create an redis connection which implements the resolver.Redis interface
var redisConn resolver.Redisctx := context.Background()
_, err := registry.RegisterService(ctx, redisConn, "service-foo", 8080, registry.WithStaticProvider("127.0.0.1"))
```## Listening addr providers
### Static IP
The option `registry.WithStaticProvider("127.0.0.1")` is used to register the service with a known IP.### AWS ECS
The option `registry.WithECSProvider()` is used to register the service which is running in aws ECS. It will detect container IP through ECS metadata automatically.