@ -95,7 +95,7 @@ func newConnStats() *ConnStats {
// HTTPAPIStats holds statistics information about
// HTTPAPIStats holds statistics information about
// a given API in the requests.
// a given API in the requests.
type HTTPAPIStats struct {
type HTTPAPIStats struct {
API Stats map [ string ] int
api Stats map [ string ] int
sync . RWMutex
sync . RWMutex
}
}
@ -106,14 +106,14 @@ func (stats *HTTPAPIStats) Inc(api string) {
if stats == nil {
if stats == nil {
return
return
}
}
if stats . API Stats == nil {
if stats . api Stats == nil {
stats . API Stats = make ( map [ string ] int )
stats . api Stats = make ( map [ string ] int )
}
}
if _ , ok := stats . API Stats[ api ] ; ok {
if _ , ok := stats . api Stats[ api ] ; ok {
stats . API Stats[ api ] ++
stats . api Stats[ api ] ++
return
return
}
}
stats . API Stats[ api ] = 1
stats . api Stats[ api ] = 1
}
}
// Dec increments the api stats counter.
// Dec increments the api stats counter.
@ -123,8 +123,8 @@ func (stats *HTTPAPIStats) Dec(api string) {
if stats == nil {
if stats == nil {
return
return
}
}
if val , ok := stats . API Stats[ api ] ; ok && val > 0 {
if val , ok := stats . api Stats[ api ] ; ok && val > 0 {
stats . API Stats[ api ] --
stats . api Stats[ api ] --
}
}
}
}
@ -132,7 +132,11 @@ func (stats *HTTPAPIStats) Dec(api string) {
func ( stats * HTTPAPIStats ) Load ( ) map [ string ] int {
func ( stats * HTTPAPIStats ) Load ( ) map [ string ] int {
stats . Lock ( )
stats . Lock ( )
defer stats . Unlock ( )
defer stats . Unlock ( )
return stats . APIStats
var apiStats = make ( map [ string ] int , len ( stats . apiStats ) )
for k , v := range stats . apiStats {
apiStats [ k ] = v
}
return apiStats
}
}
// HTTPStats holds statistics information about
// HTTPStats holds statistics information about