1
0
Fork 0

Fix connection pool stats

Also HTTP should read its own Raft address locally.
master
Philip O'Toole 3 years ago
parent ac1166fdca
commit 5613edd887

@ -254,8 +254,8 @@ func (c *Client) Stats() (map[string]interface{}, error) {
poolStats[k] = s
}
return map[string]interface{}{
"timeout": c.timeout,
"pool": poolStats,
"timeout": c.timeout,
"conn_pool_stats": poolStats,
}, nil
}

@ -1002,11 +1002,21 @@ func (s *Service) checkNodesAPIAddr(nodes []*store.Server, timeout time.Duration
wg.Add(1)
go func(id, raftAddr string) {
defer wg.Done()
apiAddr, err := s.cluster.GetNodeAPIAddr(raftAddr)
if err == nil {
mu.Lock()
apiAddrs[id] = apiAddr
mu.Unlock()
localRaftAddr, err := s.store.LeaderAddr()
if err != nil {
return
}
if raftAddr == localRaftAddr {
apiAddrs[id] = localRaftAddr
} else {
apiAddr, err := s.cluster.GetNodeAPIAddr(raftAddr)
if err == nil {
mu.Lock()
apiAddrs[id] = apiAddr
mu.Unlock()
}
}
}(n.ID, n.Addr)
}

@ -46,6 +46,7 @@ func NewChannelPool(initialCap, maxCap int, factory Factory) (Pool, error) {
c.Close()
return nil, fmt.Errorf("factory is not able to fill the pool: %s", err)
}
atomic.AddInt64(&c.nOpenConns, 1)
c.conns <- conn
}

Loading…
Cancel
Save