Cleaning up error messages and some formatting.

This commit is contained in:
Renan DelValle 2019-09-12 10:11:33 -07:00 committed by Renan DelValle
parent f72fdacfb0
commit 09628391cc
2 changed files with 9 additions and 6 deletions

View file

@ -89,7 +89,6 @@ func main() {
realis.Debug(),
}
// Check if zkUrl is available.
if zkUrl != "" {
fmt.Println("zkUrl: ", zkUrl)
clientOptions = append(clientOptions, realis.ZKUrl(zkUrl))

14
zk.go
View file

@ -117,7 +117,8 @@ func LeaderFromZKOpts(options ...ZKOpt) (string, error) {
return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", config.path)
}
return false, NewTemporaryError(errors.Wrapf(err, "Path %s doesn't exist on Zookeeper ", config.path))
return false,
NewTemporaryError(errors.Wrapf(err, "path %s doesn't exist on Zookeeper ", config.path))
}
// Search for the leader through all the children in the given path
@ -134,19 +135,22 @@ func LeaderFromZKOpts(options ...ZKOpt) (string, error) {
return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", childPath)
}
return false, NewTemporaryError(errors.Wrap(err, "Error fetching contents of leader"))
return false, NewTemporaryError(errors.Wrap(err, "error fetching contents of leader"))
}
err = json.Unmarshal([]byte(data), serviceInst)
if err != nil {
return false, NewTemporaryError(errors.Wrap(err, "Unable to unmarshall contents of leader"))
return false,
NewTemporaryError(errors.Wrap(err, "unable to unmarshal contents of leader"))
}
// Should only be one endpoint.
// This should never be encountered as it would indicate Aurora
// writing bad info into Zookeeper but is kept here as a safety net.
if len(serviceInst.AdditionalEndpoints) > 1 {
return false, NewTemporaryError(errors.New("ambiguous endpoints in json blob, Aurora wrote bad info to ZK"))
return false,
NewTemporaryError(
errors.New("ambiguous endpoints in json blob, Aurora wrote bad info to ZK"))
}
var scheme, host, port string
@ -162,7 +166,7 @@ func LeaderFromZKOpts(options ...ZKOpt) (string, error) {
}
// Leader data might not be available yet, try to fetch again.
return false, NewTemporaryError(errors.New("No leader found"))
return false, NewTemporaryError(errors.New("no leader found"))
})
if retryErr != nil {