Skip to content

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

New issue

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

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

Already on GitHub? # to your account

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

@andsens andsens force-pushed the ft-redis-sentinel branch from 0dd2cd7 to 1335e41 Compare March 19, 2024 08:50
@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
This implicitly adds support for redis sentinel HA configuration
@andsens andsens force-pushed the ft-redis-sentinel branch from 1335e41 to 1898e49 Compare March 26, 2025 08:41
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant