Skip to content

Commit

Permalink
Merge pull request #636 from go-redis/fix/pool-stats-alias
Browse files Browse the repository at this point in the history
PoolStats is an alias for pool.Stats
  • Loading branch information
vmihailenco authored Sep 11, 2017
2 parents 4c43f50 + a477631 commit 4f3778e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
11 changes: 0 additions & 11 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ var _ = Describe("pool", func() {
Timeouts: 0,
TotalConns: 1,
FreeConns: 1,
StaleConns: 0,
}))

time.Sleep(2 * time.Second)
Expand All @@ -136,6 +137,7 @@ var _ = Describe("pool", func() {
Timeouts: 0,
TotalConns: 0,
FreeConns: 0,
StaleConns: 1,
}))
})
})
13 changes: 4 additions & 9 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4f3778e

Please sign in to comment.