Przeglądaj źródła

Drop support for Go 1.6 and earlier

* Drop support for Go 1.6 and earlier
* Drop 1.5.x and 1.6.x from CI
Masayuki Izumi 6 lat temu
rodzic
commit
9f261873ed
6 zmienionych plików z 68 dodań i 138 usunięć
  1. 0 2
      .travis.yml
  2. 0 27
      redis/go16.go
  3. 17 0
      redis/pool.go
  4. 0 35
      redis/pool17.go
  5. 0 74
      redis/pool17_test.go
  6. 51 0
      redis/pool_test.go

+ 0 - 2
.travis.yml

@@ -4,8 +4,6 @@ services:
   - redis-server
   - redis-server
 
 
 go:
 go:
-  - 1.5.x
-  - 1.6.x
   - 1.7.x
   - 1.7.x
   - 1.8.x
   - 1.8.x
   - 1.9.x
   - 1.9.x

+ 0 - 27
redis/go16.go

@@ -1,27 +0,0 @@
-// +build !go1.7
-
-package redis
-
-import "crypto/tls"
-
-func cloneTLSConfig(cfg *tls.Config) *tls.Config {
-	return &tls.Config{
-		Rand:                     cfg.Rand,
-		Time:                     cfg.Time,
-		Certificates:             cfg.Certificates,
-		NameToCertificate:        cfg.NameToCertificate,
-		GetCertificate:           cfg.GetCertificate,
-		RootCAs:                  cfg.RootCAs,
-		NextProtos:               cfg.NextProtos,
-		ServerName:               cfg.ServerName,
-		ClientAuth:               cfg.ClientAuth,
-		ClientCAs:                cfg.ClientCAs,
-		InsecureSkipVerify:       cfg.InsecureSkipVerify,
-		CipherSuites:             cfg.CipherSuites,
-		PreferServerCipherSuites: cfg.PreferServerCipherSuites,
-		ClientSessionCache:       cfg.ClientSessionCache,
-		MinVersion:               cfg.MinVersion,
-		MaxVersion:               cfg.MaxVersion,
-		CurvePreferences:         cfg.CurvePreferences,
-	}
-}

+ 17 - 0
redis/pool.go

@@ -16,6 +16,7 @@ package redis
 
 
 import (
 import (
 	"bytes"
 	"bytes"
+	"context"
 	"crypto/rand"
 	"crypto/rand"
 	"crypto/sha1"
 	"crypto/sha1"
 	"errors"
 	"errors"
@@ -183,6 +184,22 @@ func (p *Pool) Get() Conn {
 	return &activeConn{p: p, pc: pc}
 	return &activeConn{p: p, pc: pc}
 }
 }
 
 
+// GetContext gets a connection using the provided context.
+//
+// The provided Context must be non-nil. If the context expires before the
+// connection is complete, an error is returned. Any expiration on the context
+// will not affect the returned connection.
+//
+// If the function completes without error, then the application must close the
+// returned connection.
+func (p *Pool) GetContext(ctx context.Context) (Conn, error) {
+	pc, err := p.get(ctx)
+	if err != nil {
+		return errorConn{err}, err
+	}
+	return &activeConn{p: p, pc: pc}, nil
+}
+
 // PoolStats contains pool statistics.
 // PoolStats contains pool statistics.
 type PoolStats struct {
 type PoolStats struct {
 	// ActiveCount is the number of connections in the pool. The count includes
 	// ActiveCount is the number of connections in the pool. The count includes

+ 0 - 35
redis/pool17.go

@@ -1,35 +0,0 @@
-// Copyright 2018 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-// +build go1.7
-
-package redis
-
-import "context"
-
-// GetContext gets a connection using the provided context.
-//
-// The provided Context must be non-nil. If the context expires before the
-// connection is complete, an error is returned. Any expiration on the context
-// will not affect the returned connection.
-//
-// If the function completes without error, then the application must close the
-// returned connection.
-func (p *Pool) GetContext(ctx context.Context) (Conn, error) {
-	pc, err := p.get(ctx)
-	if err != nil {
-		return errorConn{err}, err
-	}
-	return &activeConn{p: p, pc: pc}, nil
-}

+ 0 - 74
redis/pool17_test.go

@@ -1,74 +0,0 @@
-// Copyright 2018 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-// +build go1.7
-
-package redis_test
-
-import (
-	"context"
-	"testing"
-
-	"github.com/gomodule/redigo/redis"
-)
-
-func TestWaitPoolGetContext(t *testing.T) {
-	d := poolDialer{t: t}
-	p := &redis.Pool{
-		MaxIdle:   1,
-		MaxActive: 1,
-		Dial:      d.dial,
-		Wait:      true,
-	}
-	defer p.Close()
-	c, err := p.GetContext(context.Background())
-	if err != nil {
-		t.Fatalf("GetContext returned %v", err)
-	}
-	defer c.Close()
-}
-
-func TestWaitPoolGetAfterClose(t *testing.T) {
-	d := poolDialer{t: t}
-	p := &redis.Pool{
-		MaxIdle:   1,
-		MaxActive: 1,
-		Dial:      d.dial,
-		Wait:      true,
-	}
-	p.Close()
-	_, err := p.GetContext(context.Background())
-	if err == nil {
-		t.Fatal("expected error")
-	}
-}
-
-func TestWaitPoolGetCanceledContext(t *testing.T) {
-	d := poolDialer{t: t}
-	p := &redis.Pool{
-		MaxIdle:   1,
-		MaxActive: 1,
-		Dial:      d.dial,
-		Wait:      true,
-	}
-	defer p.Close()
-	ctx, f := context.WithCancel(context.Background())
-	f()
-	c := p.Get()
-	defer c.Close()
-	_, err := p.GetContext(ctx)
-	if err != context.Canceled {
-		t.Fatalf("got error %v, want %v", err, context.Canceled)
-	}
-}

+ 51 - 0
redis/pool_test.go

@@ -15,6 +15,7 @@
 package redis_test
 package redis_test
 
 
 import (
 import (
+	"context"
 	"errors"
 	"errors"
 	"io"
 	"io"
 	"reflect"
 	"reflect"
@@ -802,3 +803,53 @@ func BenchmarkPoolGetPing(b *testing.B) {
 		c.Close()
 		c.Close()
 	}
 	}
 }
 }
+
+func TestWaitPoolGetContext(t *testing.T) {
+	d := poolDialer{t: t}
+	p := &redis.Pool{
+		MaxIdle:   1,
+		MaxActive: 1,
+		Dial:      d.dial,
+		Wait:      true,
+	}
+	defer p.Close()
+	c, err := p.GetContext(context.Background())
+	if err != nil {
+		t.Fatalf("GetContext returned %v", err)
+	}
+	defer c.Close()
+}
+
+func TestWaitPoolGetAfterClose(t *testing.T) {
+	d := poolDialer{t: t}
+	p := &redis.Pool{
+		MaxIdle:   1,
+		MaxActive: 1,
+		Dial:      d.dial,
+		Wait:      true,
+	}
+	p.Close()
+	_, err := p.GetContext(context.Background())
+	if err == nil {
+		t.Fatal("expected error")
+	}
+}
+
+func TestWaitPoolGetCanceledContext(t *testing.T) {
+	d := poolDialer{t: t}
+	p := &redis.Pool{
+		MaxIdle:   1,
+		MaxActive: 1,
+		Dial:      d.dial,
+		Wait:      true,
+	}
+	defer p.Close()
+	ctx, f := context.WithCancel(context.Background())
+	f()
+	c := p.Get()
+	defer c.Close()
+	_, err := p.GetContext(ctx)
+	if err != context.Canceled {
+		t.Fatalf("got error %v, want %v", err, context.Canceled)
+	}
+}