Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for redis sentinel config by using redis.UniversalClient which auto-switches based on config #387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andsens
Copy link
Contributor

@andsens andsens commented Mar 18, 2024

This is one of the nice code changes where we can add more capability with the tiniest diff:
redis-go has a UniversalClient which automatically detects which redis client to use (simple, cluster, or sentinel) based on this piece of code.

func NewUniversalClient(opts *UniversalOptions) UniversalClient {
	if opts.MasterName != "" {
		return NewFailoverClient(opts.failover())
	} else if len(opts.Addrs) > 1 {
		return NewClusterClient(opts.cluster())
	}
	return NewClient(opts.simple())
}

Meaning, this PR introduces support for redis sentinel (HA failover) and also obsoletes the special redis_cluster_options setting. I haven't removed it though (legacy support). At some point a deprecation warning might be in order though.

@andsens andsens marked this pull request as draft March 19, 2024 08:42
@andsens
Copy link
Contributor Author

andsens commented Mar 19, 2024

Woops. UniversalOptions only accepts Addrs, not Addr like with the SimpleOptions. I'll update the PR

This implicitly adds support for redis sentinel HA configuration
@andsens
Copy link
Contributor Author

andsens commented Mar 19, 2024

Hmpf, I don't see a way of doing this cleanly while preserving legacy configs. I suggest breaking compatibility and simplifying the entire thing (looks around, ducks).

@andsens andsens marked this pull request as ready for review March 19, 2024 08:55
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.

1 participant