Skip to content
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

enhance: add sentinel auth config for redis #3348

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

laushunyu
Copy link
Contributor

@laushunyu laushunyu commented Mar 5, 2024

err when dial sentinel:
image

go-redis use SentinelUsername and SentinelPassword to dial sentinel

go-redis dial sentinel:


	for i, sentinelAddr := range c.sentinelAddrs {
		sentinel := NewSentinelClient(c.opt.sentinelOptions(sentinelAddr))

		masterAddr, err := sentinel.GetMasterAddrByName(ctx, c.opt.MasterName).Result()
		if err != nil {
			_ = sentinel.Close()
			if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
				return "", err
			}
			internal.Logger.Printf(ctx, "sentinel: GetMasterAddrByName master=%q failed: %s",
				c.opt.MasterName, err)
			continue
		}

go-redis make sentinel dial options

func (opt *FailoverOptions) sentinelOptions(addr string) *Options {
	return &Options{
		Addr:       addr,
		ClientName: opt.ClientName,

		Dialer:    opt.Dialer,
		OnConnect: opt.OnConnect,

		DB:       0,
		Username: opt.SentinelUsername,
		Password: opt.SentinelPassword,

@laushunyu
Copy link
Contributor Author

@gqcn need review pls

@gqcn gqcn changed the title feat(redis/config): add sentinel auth config enhance: add sentinel auth config for redis Mar 5, 2024
@gqcn
Copy link
Member

gqcn commented Mar 5, 2024

I'll check this later after ci success.

@gqcn gqcn merged commit 9b48da4 into gogf:master Mar 6, 2024
23 checks passed
# 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.

2 participants