Skip to content

Allow creation of Cluster client#27

Open
esimonov wants to merge 3 commits intogo-chi:masterfrom
esimonov:feature/allow_creation_of_cluster_client
Open

Allow creation of Cluster client#27
esimonov wants to merge 3 commits intogo-chi:masterfrom
esimonov:feature/allow_creation_of_cluster_client

Conversation

@esimonov
Copy link
Copy Markdown

What

This PR adds IsClusterMode field to httprateredis.Config, which mirrors the eponymous setting from github.com/redis/go-redis/v9. In order to process the new parameter, that dependency also had to be updated to at least v9.8.0 where this feature was introduced.

Why

Same motivation as they had when adding this field in go-redis: there's a use case when you have a single host:port pair, yet your Redis deployment is operating in cluster mode. For example, Elasticache supports setting up a Redis cluster with a single configuration endpoint. This PR makes it possible to use such clusters in httprateredis.

Other observations

The slice of addresses passed to redis.NewUniversalClient always has length 1:

redis.NewUniversalClient(&redis.UniversalOptions{
			Addrs:         []string{fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)},
			...

while go-redis documentation says that

If the number of Addrs is two or more, or IsClusterMode option is specified, a ClusterClient is returned.

This effectively means that IsClusterMode would provide the only way to create a cluster client in httprateredis.

Would you be interested in superseding the Host and Port config values with a single Addrs field of type []string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants