From 63282071decbcf08767236c300d41f576f83dc0f Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sun, 29 Sep 2013 11:15:18 +0300 Subject: [PATCH] Rename DialTCP NewTCPClient. --- v2/example_test.go | 14 +++++++------- v2/redis.go | 16 ++-------------- v2/redis_test.go | 10 +++++----- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/v2/example_test.go b/v2/example_test.go index 0ac075d..cb18080 100644 --- a/v2/example_test.go +++ b/v2/example_test.go @@ -8,7 +8,7 @@ import ( ) func ExampleTCPClient() { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: "localhost:6379", Password: "", // no password set DB: 0, // use default DB @@ -21,7 +21,7 @@ func ExampleTCPClient() { } func ExampleUnixClient() { - client := redis.DialUnix(&redis.Options{ + client := redis.NewUnixClient(&redis.Options{ Addr: "/tmp/redis.sock", }) defer client.Close() @@ -32,7 +32,7 @@ func ExampleUnixClient() { } func ExampleSetGet() { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) defer client.Close() @@ -48,7 +48,7 @@ func ExampleSetGet() { } func ExamplePipeline() { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) defer client.Close() @@ -86,7 +86,7 @@ func incr(tx *redis.Multi) ([]redis.Cmder, error) { } func ExampleTransaction() { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) defer client.Close() @@ -106,7 +106,7 @@ func ExampleTransaction() { } func ExamplePubSub() { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) defer client.Close() @@ -137,7 +137,7 @@ func Get(client *redis.Client, key string) *redis.StringCmd { } func ExampleCustomCommand() { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) defer client.Close() diff --git a/v2/redis.go b/v2/redis.go index b1b54f4..10a5eb7 100644 --- a/v2/redis.go +++ b/v2/redis.go @@ -1,7 +1,6 @@ package redis import ( - "crypto/tls" "log" "net" "os" @@ -187,25 +186,14 @@ func newClient(opt *Options, dial func() (net.Conn, error)) *Client { } } -func DialTCP(opt *Options) *Client { +func NewTCPClient(opt *Options) *Client { dial := func() (net.Conn, error) { return net.DialTimeout("tcp", opt.Addr, opt.getDialTimeout()) } return newClient(opt, dial) } -func DialTLS(opt *Options, tlsConfig *tls.Config) *Client { - dial := func() (net.Conn, error) { - conn, err := net.DialTimeout("tcp", opt.Addr, opt.getDialTimeout()) - if err != nil { - return nil, err - } - return tls.Client(conn, tlsConfig), nil - } - return newClient(opt, dial) -} - -func DialUnix(opt *Options) *Client { +func NewUnixClient(opt *Options) *Client { dial := func() (net.Conn, error) { return net.DialTimeout("unix", opt.Addr, opt.getDialTimeout()) } diff --git a/v2/redis_test.go b/v2/redis_test.go index 4bc83c2..a25709b 100644 --- a/v2/redis_test.go +++ b/v2/redis_test.go @@ -38,7 +38,7 @@ func (t *RedisConnectionTest) SetUpTest(c *C) { t.opt = &redis.Options{ Addr: redisAddr, } - t.client = redis.DialTCP(t.opt) + t.client = redis.NewTCPClient(t.opt) } func (t *RedisConnectionTest) TearDownTest(c *C) { @@ -64,7 +64,7 @@ type RedisConnectorTest struct{} var _ = Suite(&RedisConnectorTest{}) func (t *RedisConnectorTest) TestTCPConnector(c *C) { - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) ping := client.Ping() @@ -73,7 +73,7 @@ func (t *RedisConnectorTest) TestTCPConnector(c *C) { } func (t *RedisConnectorTest) TestUnixConnector(c *C) { - client := redis.DialUnix(&redis.Options{ + client := redis.NewUnixClient(&redis.Options{ Addr: "/tmp/redis.sock", }) ping := client.Ping() @@ -237,7 +237,7 @@ func Test(t *testing.T) { TestingT(t) } func (t *RedisTest) SetUpTest(c *C) { if t.client == nil { - t.client = redis.DialTCP(&redis.Options{ + t.client = redis.NewTCPClient(&redis.Options{ Addr: ":6379", }) } @@ -343,7 +343,7 @@ func (t *RedisTest) TestConnPoolRemovesBrokenConn(c *C) { c.Assert(err, IsNil) c.Assert(conn.Close(), IsNil) - client := redis.DialTCP(&redis.Options{ + client := redis.NewTCPClient(&redis.Options{ Addr: redisAddr, }) defer func() {