Skip to content

feat: support redis sentinel mode #2381#5615

Open
kayoch1n wants to merge 1 commit into
zeromicro:masterfrom
kayoch1n:feat/redis-sentinel
Open

feat: support redis sentinel mode #2381#5615
kayoch1n wants to merge 1 commit into
zeromicro:masterfrom
kayoch1n:feat/redis-sentinel

Conversation

@kayoch1n

Copy link
Copy Markdown

Issue #2381

This PR introduces Redis Sentinel support in go-zero by leveraging redis.NewFailoverClient from go-redis/v9, enabling high availability without requiring Redis Cluster.

Key changes:

  • Added new SentinelType constant to distinguish Sentinel mode
  • Updated client creation logic to use NewFailoverClient when Type: SentinelType
  • Configuration now accepts comma-separated Sentinel addresses in Host and requires MasterName
  • Added unit tests for Sentinel client initialization

Example usage:

	c := redis.MustNewRedis(redis.RedisConf{
		Type: redis.SentinelType,
		Host: strings.Join([]string{
			"10.244.2.24:26379", // the addresses of sentinel instances
			"10.244.1.15:26379",
			"10.244.2.26:26379",
		}, ","),
		MasterName: "mymaster",
	})

The returned *redis.Client remains fully compatible with the existing RedisNode interface.

This is a recreated PR of #5438

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