From 911064ea124bc3ee0eb25410cde4c807f355e2f8 Mon Sep 17 00:00:00 2001 From: nange Date: Thu, 16 Nov 2017 13:12:14 +0800 Subject: [PATCH] PoolConn add IsUnusable func --- conn.go | 4 ++++ heap_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/conn.go b/conn.go index 7393e55..b86a480 100644 --- a/conn.go +++ b/conn.go @@ -31,6 +31,10 @@ func (pc *PoolConn) MarkUnusable() { pc.unusable = true } +func (pc *PoolConn) IsUnusable() bool { + return pc.unusable +} + func (pc *PoolConn) close() error { return pc.Conn.Close() } diff --git a/heap_test.go b/heap_test.go index 62a3ed0..046a0c4 100644 --- a/heap_test.go +++ b/heap_test.go @@ -117,6 +117,9 @@ func TestPoolConcurrent2(t *testing.T) { time.Sleep(time.Second) if i >= MaxCap-10 { conn.(*PoolConn).MarkUnusable() + if !conn.(*PoolConn).IsUnusable() { + t.Errorf("after mark unusable, IsUnusable() should return true") + } } conn.Close() }(conn, i)