Skip to content

Commit 09176ef

Browse files
committed
PoolStats is an alias for pool.Stats
1 parent aeb93fd commit 09176ef

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

options.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,3 @@ func newConnPool(opt *Options) *pool.ConnPool {
198198
IdleCheckFrequency: opt.IdleCheckFrequency,
199199
})
200200
}
201-
202-
// PoolStats contains pool state information and accumulated stats.
203-
type PoolStats struct {
204-
Requests uint32 // number of times a connection was requested by the pool
205-
Hits uint32 // number of times free connection was found in the pool
206-
Timeouts uint32 // number of times a wait timeout occurred
207-
208-
TotalConns uint32 // number of total connections in the pool
209-
FreeConns uint32 // number of free connections in the pool
210-
StaleConns uint32 // number of stale connections removed from the pool
211-
}

pool_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ var _ = Describe("pool", func() {
125125
Timeouts: 0,
126126
TotalConns: 1,
127127
FreeConns: 1,
128+
StaleConns: 0,
128129
}))
129130

130131
time.Sleep(2 * time.Second)
@@ -136,6 +137,7 @@ var _ = Describe("pool", func() {
136137
Timeouts: 0,
137138
TotalConns: 0,
138139
FreeConns: 0,
140+
StaleConns: 1,
139141
}))
140142
})
141143
})

redis.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,12 @@ func (c *Client) Options() *Options {
352352
return c.opt
353353
}
354354

355+
type PoolStats pool.Stats
356+
355357
// PoolStats returns connection pool stats.
356358
func (c *Client) PoolStats() *PoolStats {
357-
s := c.connPool.Stats()
358-
return &PoolStats{
359-
Requests: s.Requests,
360-
Hits: s.Hits,
361-
Timeouts: s.Timeouts,
362-
363-
TotalConns: s.TotalConns,
364-
FreeConns: s.FreeConns,
365-
}
359+
stats := c.connPool.Stats()
360+
return (*PoolStats)(stats)
366361
}
367362

368363
func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) {

0 commit comments

Comments
 (0)