Simplifying retry mechanism for Thrift Calls (#56)
* Deleting permament error as it doesn't make sense. Just return a plain old error and that will be considered permanent. * Removing double closure at as it's unmaintainable and can be error prone. Separated back offs into a generic one and a thrift call specific one. * ZK leader finder now returns a temporary error instead of constantly no leader found and quitting. It could be that the leader info is being propagated so it's worth trying another time. * Adding more logging to the retry. * Wrapping lock and unlock in an anonymous function so that we can use defer on unlock such that it is called in the case of a panic.
This commit is contained in:
parent
64948c3712
commit
a43dc81ea8
4 changed files with 166 additions and 380 deletions
5
zk.go
5
zk.go
|
@ -93,11 +93,12 @@ func LeaderFromZK(cluster Cluster) (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return false, errors.New("No leader found")
|
||||
// Leader data might not be available yet, try to fetch again.
|
||||
return false, NewTemporaryError(errors.New("No leader found"))
|
||||
})
|
||||
|
||||
if retryErr != nil {
|
||||
return "", errors.Wrapf(retryErr, "Failed to determine leader after %v attempts", defaultBackoff.Steps)
|
||||
return "", NewTimeoutError(errors.Wrapf(retryErr, "Failed to determine leader after %v attempts", defaultBackoff.Steps))
|
||||
}
|
||||
|
||||
return zkurl, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue