File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ type Pooler interface {
6868 AddPoolHook (hook PoolHook )
6969 RemovePoolHook (hook PoolHook )
7070
71+ TrackConn (* Conn )
72+ UntrackConn (* Conn )
73+
7174 Close () error
7275}
7376
@@ -736,3 +739,20 @@ func (p *ConnPool) isHealthyConn(cn *Conn, now time.Time) bool {
736739 }
737740 return true
738741}
742+
743+ func (p * ConnPool ) TrackConn (cn * Conn ) {
744+ p .connsMu .Lock ()
745+ p .conns = append (p .conns , cn )
746+ p .connsMu .Unlock ()
747+ }
748+
749+ func (p * ConnPool ) UntrackConn (cn * Conn ) {
750+ p .connsMu .Lock ()
751+ for i , c := range p .conns {
752+ if c == cn {
753+ p .conns = append (p .conns [:i ], p .conns [i + 1 :]... )
754+ break
755+ }
756+ }
757+ p .connsMu .Unlock ()
758+ }
Original file line number Diff line number Diff line change @@ -1071,10 +1071,12 @@ func (c *Client) pubSub() *PubSub {
10711071 return nil , err
10721072 }
10731073
1074+ c .pool .TrackConn (cn )
10741075 return cn , nil
10751076 },
10761077 closeConn : func (cn * pool.Conn ) error {
10771078 _ = cn .Close ()
1079+ c .pool .UntrackConn (cn )
10781080 return nil
10791081 },
10801082 pushProcessor : c .pushProcessor ,
You can’t perform that action at this time.
0 commit comments