Skip to content

Commit

Permalink
Use safe functions to set alias and avoid concurrent writes to a sahr…
Browse files Browse the repository at this point in the history
…ed object
  • Loading branch information
roivaz committed Jul 26, 2023
1 parent 591ad83 commit b919e81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/redis/server/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/go-redis/redis/v8"
)

// SentinelPool holds a thread safe list of Servers.
// ServerPool holds a thread safe list of Servers.
// It is intended for client reuse throughout the code.
type ServerPool struct {
servers []*Server
Expand Down Expand Up @@ -42,8 +42,8 @@ func (pool *ServerPool) GetServer(connectionString string, alias *string) (*Serv
}
if srv = pool.indexByHostPort()[opts.Addr]; srv != nil {
// set the alias if it has been passed down
if alias != nil {
srv.alias = *alias
if alias != nil && srv.GetAlias() != *alias {
srv.SetAlias(*alias)
}
return srv, nil
}
Expand Down

0 comments on commit b919e81

Please sign in to comment.