Merge pull request #83 from codysoyland/expvar-compatibility

Initialize expvar lazily to prevent panic if importing both Pilosa v1 and v2
This commit is contained in:
Cody Soyland 2020-01-02 17:56:42 -06:00 committed by GitHub
commit 29f7448b89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,7 +25,7 @@ import (
)
// Expvar global expvar map.
var Expvar = expvar.NewMap("index")
var Expvar *expvar.Map
// StatsClient represents a client to a stats server.
type StatsClient interface {
@ -90,6 +90,9 @@ type expvarStatsClient struct {
// NewExpvarStatsClient returns a new instance of ExpvarStatsClient.
// This client points at the root of the expvar index map.
func NewExpvarStatsClient() *expvarStatsClient {
if Expvar == nil {
Expvar = expvar.NewMap("index")
}
return &expvarStatsClient{
m: Expvar,
}