1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add pool instrumentation.

This commit is contained in:
Anatolii Mihailenco
2016-01-19 18:36:40 +02:00
parent dd1ac33826
commit f7a4bd5023
5 changed files with 57 additions and 0 deletions

View File

@ -56,6 +56,22 @@ func (c *ClusterClient) Watch(keys ...string) (*Multi, error) {
return client.Watch(keys...)
}
// PoolStats returns accumulated connection pool stats
func (c *ClusterClient) PoolStats() *PoolStats {
acc := PoolStats{}
c.clientsMx.RLock()
for _, client := range c.clients {
m := client.PoolStats()
acc.TotalConns += m.TotalConns
acc.FreeConns += m.FreeConns
acc.Requests += m.Requests
acc.Waits += m.Waits
acc.Timeouts += m.Timeouts
}
c.clientsMx.RUnlock()
return &acc
}
// Close closes the cluster client, releasing any open resources.
//
// It is rare to Close a ClusterClient, as the ClusterClient is meant
@ -306,6 +322,7 @@ type ClusterOptions struct {
ReadTimeout time.Duration
WriteTimeout time.Duration
// PoolSize applies per redis node and not for the whole cluster.
PoolSize int
PoolTimeout time.Duration
IdleTimeout time.Duration