ServerAddressProvider interface also returns an error now

This commit is contained in:
Preetha Appan 2017-08-29 14:12:32 -05:00
parent edb408bc22
commit b4a9d77d49
1 changed files with 4 additions and 5 deletions

View File

@ -1049,16 +1049,15 @@ func (s *Server) GetWANCoordinate() (*coordinate.Coordinate, error) {
return s.serfWAN.GetCoordinate() return s.serfWAN.GetCoordinate()
} }
func (s *Server) ServerAddr(id raft.ServerID) raft.ServerAddress { func (s *Server) ServerAddr(id raft.ServerID) (raft.ServerAddress, error) {
if string(id) == string(s.config.NodeID) { if string(id) == string(s.config.NodeID) {
return raft.ServerAddress(s.config.RPCAddr.String()) return raft.ServerAddress(s.config.RPCAddr.String()), nil
} }
addr, err := s.router.GetServerAddressByID(s.config.Datacenter, string(id)) addr, err := s.router.GetServerAddressByID(s.config.Datacenter, string(id))
if err != nil { if err != nil {
s.logger.Println("[WARN] Unable to find address for raft server id %v", id) return "", err
return raft.ServerAddress("")
} }
return raft.ServerAddress(addr) return raft.ServerAddress(addr), nil
} }
// Atomically sets a readiness state flag when leadership is obtained, to indicate that server is past its barrier write // Atomically sets a readiness state flag when leadership is obtained, to indicate that server is past its barrier write