config client: handle config changes correctly
MODIFY
go/client.go
go/client.go
@@ -31,7 +31,7 @@ type RedisSystem struct {
// ClientState holds the client state.
type ClientState struct {
- opts ClientOptions
+ opts *ClientOptions
mutex sync.Mutex
ws *websocket.Conn
input chan MsgBody
@@ -362,7 +362,7 @@ func RunConfigurationClient(o ClientOptions) error {
logInfo("client started with options: %+v\n", o)
for !interrupted {
state := &ClientState{
- opts: o,
+ opts: &o,
readerDone: make(chan struct{}, 1),
writerDone: make(chan struct{}, 1),
redisSystems: make(map[string]*RedisSystem, 0),

MODIFY
go/server.go
go/server.go
@@ -74,7 +74,7 @@ type FailoverState struct {
// ServerState holds the server state.
type ServerState struct {
- opts ServerOptions // Options passed to the constructor.
+ opts *ServerOptions // Options passed to the constructor.
mutex sync.Mutex // Mutex for changing opts.Config.
clientIds StringSet // The list of clients we know and which take part in master election.
clientChannels ChannelMap // Channels we use to communicate with client websocket goroutines.
@@ -475,7 +475,7 @@ func (s *ServerState) handleWebSocketMsg(msg *WsMsg) {
// NewServerState creates partially initialized ServerState.
func NewServerState(o ServerOptions) *ServerState {
s := &ServerState{clientChannels: make(ChannelMap), notificationChannels: make(ChannelSet)}
- s.opts = o
+ s.opts = &o
s.determineFailoverConfidenceLevel()
s.upgrader = websocket.Upgrader{
ReadBufferSize: 1024,

config client: handle config changes correctly