1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-16 23:40:55 +03:00

Rework pipeline retrying

This commit is contained in:
Vladimir Mihailenco
2017-08-31 15:22:47 +03:00
parent 0daeac9c3e
commit dbd2c99ba9
13 changed files with 388 additions and 256 deletions

View File

@ -13,10 +13,23 @@ type RedisError string
func (e RedisError) Error() string { return string(e) }
func IsRetryableError(err error) bool {
return IsNetworkError(err) || err.Error() == "ERR max number of clients reached"
if IsNetworkError(err) {
return true
}
s := err.Error()
if s == "ERR max number of clients reached" {
return true
}
if strings.HasPrefix(s, "LOADING ") {
return true
}
if strings.HasPrefix(s, "CLUSTERDOWN ") {
return true
}
return false
}
func IsInternalError(err error) bool {
func IsRedisError(err error) bool {
_, ok := err.(RedisError)
return ok
}
@ -33,7 +46,7 @@ func IsBadConn(err error, allowTimeout bool) bool {
if err == nil {
return false
}
if IsInternalError(err) {
if IsRedisError(err) {
return false
}
if allowTimeout {
@ -45,7 +58,7 @@ func IsBadConn(err error, allowTimeout bool) bool {
}
func IsMovedError(err error) (moved bool, ask bool, addr string) {
if !IsInternalError(err) {
if !IsRedisError(err) {
return
}
@ -69,7 +82,3 @@ func IsMovedError(err error) (moved bool, ask bool, addr string) {
func IsLoadingError(err error) bool {
return strings.HasPrefix(err.Error(), "LOADING ")
}
func IsClusterDownError(err error) bool {
return strings.HasPrefix(err.Error(), "CLUSTERDOWN ")
}