From 7f5b63da851237c27a3d06795129f93ccc7a059e Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 18 Jun 2018 13:07:31 +0300 Subject: [PATCH] Close read-only connections --- internal/error.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/error.go b/internal/error.go index 7b41957..e0ff863 100644 --- a/internal/error.go +++ b/internal/error.go @@ -19,6 +19,9 @@ func IsRetryableError(err error, retryNetError bool) bool { if strings.HasPrefix(s, "LOADING ") { return true } + if strings.HasPrefix(s, "READONLY ") { + return true + } if strings.HasPrefix(s, "CLUSTERDOWN ") { return true } @@ -38,16 +41,12 @@ func IsNetworkError(err error) bool { return ok } -func IsReadOnlyError(err error) bool { - return strings.HasPrefix(err.Error(), "READONLY ") -} - func IsBadConn(err error, allowTimeout bool) bool { if err == nil { return false } if IsRedisError(err) { - return false + return strings.HasPrefix(err.Error(), "READONLY ") } if allowTimeout { if netErr, ok := err.(net.Error); ok && netErr.Timeout() {