Skip to content

Commit

Permalink
PoolConn add IsUnusable func
Browse files Browse the repository at this point in the history
  • Loading branch information
nange committed Nov 16, 2017
1 parent 5ad858a commit 911064e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
3 changes: 3 additions & 0 deletions heap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 911064e

Please sign in to comment.