summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-redis/redis/internal
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-08-17 17:19:06 -0700
committerGitHub <noreply@github.com>2017-08-17 17:19:06 -0700
commit96eab1202717e073782ec399a4e0820cae15b1bb (patch)
tree011012982be971c7e9ef91466f026bc0956ac9a2 /vendor/github.com/go-redis/redis/internal
parent2c895ee66eed626721135acfcc48254c6e3f3b29 (diff)
downloadchat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.gz
chat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.bz2
chat-96eab1202717e073782ec399a4e0820cae15b1bb.zip
Updating server dependancies. (#7246)
Diffstat (limited to 'vendor/github.com/go-redis/redis/internal')
-rw-r--r--vendor/github.com/go-redis/redis/internal/error.go (renamed from vendor/github.com/go-redis/redis/internal/errors.go)6
-rw-r--r--vendor/github.com/go-redis/redis/internal/internal.go13
-rw-r--r--vendor/github.com/go-redis/redis/internal/internal_test.go9
-rw-r--r--vendor/github.com/go-redis/redis/internal/pool/pool.go4
4 files changed, 19 insertions, 13 deletions
diff --git a/vendor/github.com/go-redis/redis/internal/errors.go b/vendor/github.com/go-redis/redis/internal/error.go
index c93e00818..90f6503a1 100644
--- a/vendor/github.com/go-redis/redis/internal/errors.go
+++ b/vendor/github.com/go-redis/redis/internal/error.go
@@ -67,9 +67,9 @@ func IsMovedError(err error) (moved bool, ask bool, addr string) {
}
func IsLoadingError(err error) bool {
- return strings.HasPrefix(err.Error(), "LOADING")
+ return strings.HasPrefix(err.Error(), "LOADING ")
}
-func IsExecAbortError(err error) bool {
- return strings.HasPrefix(err.Error(), "EXECABORT")
+func IsClusterDownError(err error) bool {
+ return strings.HasPrefix(err.Error(), "CLUSTERDOWN ")
}
diff --git a/vendor/github.com/go-redis/redis/internal/internal.go b/vendor/github.com/go-redis/redis/internal/internal.go
index fb4efa5f0..ad3fc3c9f 100644
--- a/vendor/github.com/go-redis/redis/internal/internal.go
+++ b/vendor/github.com/go-redis/redis/internal/internal.go
@@ -5,19 +5,20 @@ import (
"time"
)
-const retryBackoff = 8 * time.Millisecond
-
// Retry backoff with jitter sleep to prevent overloaded conditions during intervals
// https://www.awsarchitectureblog.com/2015/03/backoff.html
-func RetryBackoff(retry int, maxRetryBackoff time.Duration) time.Duration {
+func RetryBackoff(retry int, minBackoff, maxBackoff time.Duration) time.Duration {
if retry < 0 {
retry = 0
}
- backoff := retryBackoff << uint(retry)
- if backoff > maxRetryBackoff {
- backoff = maxRetryBackoff
+ backoff := minBackoff << uint(retry)
+ if backoff > maxBackoff || backoff < minBackoff {
+ backoff = maxBackoff
}
+ if backoff == 0 {
+ return 0
+ }
return time.Duration(rand.Int63n(int64(backoff)))
}
diff --git a/vendor/github.com/go-redis/redis/internal/internal_test.go b/vendor/github.com/go-redis/redis/internal/internal_test.go
index 5c7000e1e..56ff611e1 100644
--- a/vendor/github.com/go-redis/redis/internal/internal_test.go
+++ b/vendor/github.com/go-redis/redis/internal/internal_test.go
@@ -2,15 +2,16 @@ package internal
import (
"testing"
- . "github.com/onsi/gomega"
"time"
+
+ . "github.com/onsi/gomega"
)
func TestRetryBackoff(t *testing.T) {
RegisterTestingT(t)
-
- for i := -1; i<= 8; i++ {
- backoff := RetryBackoff(i, 512*time.Millisecond)
+
+ for i := -1; i <= 16; i++ {
+ backoff := RetryBackoff(i, time.Millisecond, 512*time.Millisecond)
Expect(backoff >= 0).To(BeTrue())
Expect(backoff <= 512*time.Millisecond).To(BeTrue())
}
diff --git a/vendor/github.com/go-redis/redis/internal/pool/pool.go b/vendor/github.com/go-redis/redis/internal/pool/pool.go
index a4e650847..25e78aa3c 100644
--- a/vendor/github.com/go-redis/redis/internal/pool/pool.go
+++ b/vendor/github.com/go-redis/redis/internal/pool/pool.go
@@ -119,6 +119,10 @@ func (p *ConnPool) NewConn() (*Conn, error) {
func (p *ConnPool) tryDial() {
for {
+ if p.closed() {
+ return
+ }
+
conn, err := p.opt.Dialer()
if err != nil {
p.setLastDialError(err)