go-redis
go-redis copied to clipboard
add/remove shards in redis ring
We use redis ring client to shard access to redis for our rate limit infrastructure in Kubernetes https://opensource.zalando.com/skipper/tutorials/ratelimit/#redis-based-cluster-ratelimits. I would like to add and remove shards on demand while Kubernetes is scaling-out redis instances. I tried to implement it by closing and recreating the redis ring, but I think it would be better (less locks required) to trigger it via a library call.
One idea I had was to have a func() []string
that is called every configurable time.Duration with a time.Ticker to set the Members and propagate these into the library ringShards. Or we could also do the triggering ourselves and the library just provides ReconfigureShards(shards []string)
.
Do you have a better idea how to make this happen?
I am willing to create a PR if it makes sense for you.
@szuecs I think that providing API like ring.SetAddrs(addrs map[string]string)
is a better way forward and I would gladly review such a PR :+1:
@vmihailenco can you check the updated PR? Thanks!
I think we can close this one