mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Add auto-retry and MaxRetries option. Fixes #84.
This commit is contained in:
10
error.go
10
error.go
@ -26,7 +26,7 @@ func (err redisError) Error() string {
|
||||
}
|
||||
|
||||
func isNetworkError(err error) bool {
|
||||
if _, ok := err.(*net.OpError); ok || err == io.EOF {
|
||||
if _, ok := err.(net.Error); ok || err == io.EOF {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -53,3 +53,11 @@ func isMovedError(err error) (moved bool, ask bool, addr string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// shouldRetry reports whether failed command should be retried.
|
||||
func shouldRetry(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return isNetworkError(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user