Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoolStats is an alias for pool.Stats #636

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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