Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/redis/go-redis/v9/internal"
"github.com/redis/go-redis/v9/internal/pool"
"github.com/redis/go-redis/v9/internal/rand"
"github.com/redis/go-redis/v9/internal/util"
"github.com/redis/go-redis/v9/push"
)

Expand Down Expand Up @@ -843,6 +842,11 @@ func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) {
}
}

// short circuit if no sentinels configured
if len(c.sentinelAddrs) == 0 {
return "", errors.New("redis: no sentinels configured")
}

var (
masterAddr string
wg sync.WaitGroup
Expand Down Expand Up @@ -890,16 +894,20 @@ func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) {
}

func joinErrors(errs []error) string {
if len(errs) == 0 {
return ""
}
if len(errs) == 1 {
return errs[0].Error()
}

b := []byte(errs[0].Error())
var b strings.Builder
b.WriteString(errs[0].Error())
for _, err := range errs[1:] {
b = append(b, '\n')
b = append(b, err.Error()...)
b.WriteByte('\n')
b.WriteString(err.Error())
}
return util.BytesToString(b)
return b.String()
Comment thread
ndyakov marked this conversation as resolved.
Outdated
}

func (c *sentinelFailover) replicaAddrs(ctx context.Context, useDisconnected bool) ([]string, error) {
Expand Down
Loading