Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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
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.

2 participants