Skip to content

Commit bfe9f43

Browse files
committed
remove unused methods
1 parent b865950 commit bfe9f43

File tree

7 files changed

+10
-35
lines changed

7 files changed

+10
-35
lines changed

hitless/pool_hook_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ func (mp *mockPool) RemovePoolHook(hook pool.PoolHook) {
100100
// Mock implementation - do nothing
101101
}
102102

103-
func (mp *mockPool) TrackConn(conn *pool.Conn) {
104-
// Mock implementation - do nothing
105-
}
106-
107-
func (mp *mockPool) UntrackConn(conn *pool.Conn) {
108-
// Mock implementation - do nothing
109-
}
110-
111103
func (mp *mockPool) Close() error {
112104
return nil
113105
}

internal/pool/pool.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ type Pooler interface {
7070
AddPoolHook(hook PoolHook)
7171
RemovePoolHook(hook PoolHook)
7272

73-
TrackConn(*Conn)
74-
UntrackConn(*Conn)
75-
7673
Close() error
7774
}
7875

@@ -758,15 +755,4 @@ func (p *ConnPool) isHealthyConn(cn *Conn, now time.Time) bool {
758755
return true
759756
}
760757

761-
func (p *ConnPool) TrackConn(cn *Conn) {
762-
p.connsMu.Lock()
763-
p.poolSize.Add(1)
764-
p.conns[cn.GetID()] = cn
765-
p.connsMu.Unlock()
766-
}
767758

768-
func (p *ConnPool) UntrackConn(cn *Conn) {
769-
p.connsMu.Lock()
770-
delete(p.conns, cn.GetID())
771-
p.connsMu.Unlock()
772-
}

internal/pool/pool_single.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,3 @@ func (p *SingleConnPool) Stats() *Stats {
6262
func (p *SingleConnPool) AddPoolHook(hook PoolHook) {}
6363

6464
func (p *SingleConnPool) RemovePoolHook(hook PoolHook) {}
65-
66-
func (p *SingleConnPool) TrackConn(cn *Conn) {}
67-
68-
func (p *SingleConnPool) UntrackConn(cn *Conn) {}

internal/pool/pool_sticky.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,3 @@ func (p *StickyConnPool) Stats() *Stats {
203203
func (p *StickyConnPool) AddPoolHook(hook PoolHook) {}
204204

205205
func (p *StickyConnPool) RemovePoolHook(hook PoolHook) {}
206-
207-
func (p *StickyConnPool) TrackConn(cn *Conn) {}
208-
209-
func (p *StickyConnPool) UntrackConn(cn *Conn) {}

osscluster.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,9 @@ func (c *ClusterClient) pubSub() *PubSub {
18831883
return cn, nil
18841884
},
18851885
closeConn: func(cn *pool.Conn) error {
1886-
err := node.Client.connPool.CloseConn(cn)
1886+
// Untrack connection from PubSubPool
1887+
node.Client.pubSubPool.UntrackConn(cn)
1888+
err := cn.Close()
18871889
node = nil
18881890
return err
18891891
},

redis.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,10 +1061,12 @@ func (c *Client) pubSub() *PubSub {
10611061
_ = cn.Close()
10621062
return nil, err
10631063
}
1064+
// Track connection in PubSubPool
10641065
c.pubSubPool.TrackConn(cn)
10651066
return cn, nil
10661067
},
10671068
closeConn: func(cn *pool.Conn) error {
1069+
// Untrack connection from PubSubPool
10681070
c.pubSubPool.UntrackConn(cn)
10691071
_ = cn.Close()
10701072
return nil

sentinel.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,22 +580,23 @@ func (c *SentinelClient) pubSub() *PubSub {
580580
pubsub := &PubSub{
581581
opt: c.opt,
582582
newConn: func(ctx context.Context, addr string, channels []string) (*pool.Conn, error) {
583-
netConn, err := c.dialHook(ctx, c.opt.Network, addr)
583+
cn, err := c.pubSubPool.NewConn(ctx, c.opt.Network, addr, channels)
584584
if err != nil {
585585
return nil, err
586586
}
587-
cn := pool.NewConnWithBufferSize(netConn, c.opt.ReadBufferSize, c.opt.WriteBufferSize)
588-
589587
// will return nil if already initialized
590588
err = c.initConn(ctx, cn)
591589
if err != nil {
592590
_ = cn.Close()
593591
return nil, err
594592
}
595-
593+
// Track connection in PubSubPool
594+
c.pubSubPool.TrackConn(cn)
596595
return cn, nil
597596
},
598597
closeConn: func(cn *pool.Conn) error {
598+
// Untrack connection from PubSubPool
599+
c.pubSubPool.UntrackConn(cn)
599600
_ = cn.Close()
600601
return nil
601602
},

0 commit comments

Comments
 (0)