Skip to content

Add ClusterOptions.NewClient hook #1332

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

Merged
merged 1 commit into from
May 21, 2020
Merged

Conversation

vmihailenco
Copy link
Collaborator

Replaces #1316

Can be used like this

rdb := redis.NewClusterClient(&redis.ClusterOptions{
	Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},

	NewClient: func(opt *redis.Options) *redis.Client {
		opt.Limiter = getLimiter(opt)
		return redis.NewClient(opt)
	},
})

@walktall
Copy link

@vmihailenco Thanks! LGTM!

@vmihailenco vmihailenco merged commit 8f52186 into master May 21, 2020
@vmihailenco vmihailenco deleted the feature/cluster-new-client branch May 21, 2020 06:52
@ThomasJannaud
Copy link

ThomasJannaud commented May 22, 2020

Thanks!

for anyone needed a limiter per options:

opts.NewClient = func(opt *redis.Options) *redis.Client {
  opt.Limiter = _myCircuitBreaker[addr]  // you need to implement your own circuit breaker, one per address, careful of r/w access on the map too
  return redis.NewClient(opt)
}
client := redis.NewClusterClient(opts)

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.

3 participants