Merge pull request #636 from go-redis/fix/pool-stats-alias

PoolStats is an alias for pool.Stats
This commit is contained in:
Vladimir Mihailenco 2017-09-11 10:38:23 +03:00 committed by GitHub
commit fdafb11e5f
3 changed files with 6 additions and 20 deletions

View File

@ -198,14 +198,3 @@ func newConnPool(opt *Options) *pool.ConnPool {
IdleCheckFrequency: opt.IdleCheckFrequency, 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
}

View File

@ -125,6 +125,7 @@ var _ = Describe("pool", func() {
Timeouts: 0, Timeouts: 0,
TotalConns: 1, TotalConns: 1,
FreeConns: 1, FreeConns: 1,
StaleConns: 0,
})) }))
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
@ -136,6 +137,7 @@ var _ = Describe("pool", func() {
Timeouts: 0, Timeouts: 0,
TotalConns: 0, TotalConns: 0,
FreeConns: 0, FreeConns: 0,
StaleConns: 1,
})) }))
}) })
}) })

View File

@ -352,17 +352,12 @@ func (c *Client) Options() *Options {
return c.opt return c.opt
} }
type PoolStats pool.Stats
// PoolStats returns connection pool stats. // PoolStats returns connection pool stats.
func (c *Client) PoolStats() *PoolStats { func (c *Client) PoolStats() *PoolStats {
s := c.connPool.Stats() stats := c.connPool.Stats()
return &PoolStats{ return (*PoolStats)(stats)
Requests: s.Requests,
Hits: s.Hits,
Timeouts: s.Timeouts,
TotalConns: s.TotalConns,
FreeConns: s.FreeConns,
}
} }
func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) {