From 8d3747808e5d1b325b5559555568b4dbab83e094 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 23 Aug 2018 16:13:42 +0300 Subject: [PATCH] internal: retry timeout --- internal/error.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/error.go b/internal/error.go index e0ff8632..bda97baa 100644 --- a/internal/error.go +++ b/internal/error.go @@ -8,9 +8,15 @@ import ( "github.com/go-redis/redis/internal/proto" ) -func IsRetryableError(err error, retryNetError bool) bool { - if IsNetworkError(err) { - return retryNetError +func IsRetryableError(err error, retryTimeout bool) bool { + if err == io.EOF { + return true + } + if netErr, ok := err.(net.Error); ok { + if netErr.Timeout() { + return retryTimeout + } + return true } s := err.Error() if s == "ERR max number of clients reached" { @@ -33,14 +39,6 @@ func IsRedisError(err error) bool { return ok } -func IsNetworkError(err error) bool { - if err == io.EOF { - return true - } - _, ok := err.(net.Error) - return ok -} - func IsBadConn(err error, allowTimeout bool) bool { if err == nil { return false