diff --git a/cluster/client.go b/cluster/client.go index 0edde41e..403f58d4 100644 --- a/cluster/client.go +++ b/cluster/client.go @@ -347,7 +347,7 @@ func (c *Client) dial(nodeAddr string, timeout time.Duration) (net.Conn, error) } func handleConnError(conn net.Conn) { - if pc, ok := conn.(*pool.PoolConn); ok { + if pc, ok := conn.(*pool.Conn); ok { pc.MarkUnusable() } } diff --git a/tcp/pool/channel_test.go b/tcp/pool/channel_test.go index 13b8cb1e..069157b8 100644 --- a/tcp/pool/channel_test.go +++ b/tcp/pool/channel_test.go @@ -40,7 +40,7 @@ func TestPool_Get_Impl(t *testing.T) { t.Errorf("Get error: %s", err) } - _, ok := conn.(*PoolConn) + _, ok := conn.(*Conn) if !ok { t.Errorf("Conn is not of type poolConn") } @@ -135,7 +135,7 @@ func TestPool_PutUnusableConn(t *testing.T) { } conn, _ = p.Get() - if pc, ok := conn.(*PoolConn); !ok { + if pc, ok := conn.(*Conn); !ok { t.Errorf("impossible") } else { pc.MarkUnusable() diff --git a/tcp/pool/conn.go b/tcp/pool/conn.go index 44872c66..7778b3ec 100644 --- a/tcp/pool/conn.go +++ b/tcp/pool/conn.go @@ -5,17 +5,17 @@ import ( "sync" ) -// PoolConn is a wrapper around net.Conn to modify the the behavior of +// Conn is a wrapper around net.Conn to modify the the behavior of // net.Conn's Close() method. -type PoolConn struct { +type Conn struct { net.Conn mu sync.RWMutex c *channelPool unusable bool } -// Close puts the given connects back to the pool instead of closing it. -func (p *PoolConn) Close() error { +// Close puts the given connection back into the pool instead of closing it. +func (p *Conn) Close() error { p.mu.RLock() defer p.mu.RUnlock() @@ -29,7 +29,7 @@ func (p *PoolConn) Close() error { } // MarkUnusable marks the connection not usable any more, to let the pool close it instead of returning it to pool. -func (p *PoolConn) MarkUnusable() { +func (p *Conn) MarkUnusable() { p.mu.Lock() p.unusable = true p.mu.Unlock() @@ -37,7 +37,7 @@ func (p *PoolConn) MarkUnusable() { // newConn wraps a standard net.Conn to a poolConn net.Conn. func (c *channelPool) wrapConn(conn net.Conn) net.Conn { - p := &PoolConn{c: c} + p := &Conn{c: c} p.Conn = conn return p } diff --git a/tcp/pool/conn_test.go b/tcp/pool/conn_test.go index 55f9237f..c7092330 100644 --- a/tcp/pool/conn_test.go +++ b/tcp/pool/conn_test.go @@ -6,5 +6,5 @@ import ( ) func TestConn_Impl(t *testing.T) { - var _ net.Conn = new(PoolConn) + var _ net.Conn = new(Conn) }