From 09176ef4fa3eae87ed310d02c51d9c6829347f93 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 11 Sep 2017 10:12:00 +0300 Subject: [PATCH] PoolStats is an alias for pool.Stats --- options.go | 11 ----------- pool_test.go | 2 ++ redis.go | 13 ++++--------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/options.go b/options.go index 6c4e68d..7564805 100644 --- a/options.go +++ b/options.go @@ -198,14 +198,3 @@ func newConnPool(opt *Options) *pool.ConnPool { IdleCheckFrequency: opt.IdleCheckFrequency, }) } - -// PoolStats contains pool state information and accumulated stats. -type PoolStats struct { - Requests uint32 // number of times a connection was requested by the pool - Hits uint32 // number of times free connection was found in the pool - Timeouts uint32 // number of times a wait timeout occurred - - TotalConns uint32 // number of total connections in the pool - FreeConns uint32 // number of free connections in the pool - StaleConns uint32 // number of stale connections removed from the pool -} diff --git a/pool_test.go b/pool_test.go index 34a548a..2cc1cdf 100644 --- a/pool_test.go +++ b/pool_test.go @@ -125,6 +125,7 @@ var _ = Describe("pool", func() { Timeouts: 0, TotalConns: 1, FreeConns: 1, + StaleConns: 0, })) time.Sleep(2 * time.Second) @@ -136,6 +137,7 @@ var _ = Describe("pool", func() { Timeouts: 0, TotalConns: 0, FreeConns: 0, + StaleConns: 1, })) }) }) diff --git a/redis.go b/redis.go index d18a152..70a1753 100644 --- a/redis.go +++ b/redis.go @@ -352,17 +352,12 @@ func (c *Client) Options() *Options { return c.opt } +type PoolStats pool.Stats + // PoolStats returns connection pool stats. func (c *Client) PoolStats() *PoolStats { - s := c.connPool.Stats() - return &PoolStats{ - Requests: s.Requests, - Hits: s.Hits, - Timeouts: s.Timeouts, - - TotalConns: s.TotalConns, - FreeConns: s.FreeConns, - } + stats := c.connPool.Stats() + return (*PoolStats)(stats) } func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) {