diff --git a/stats/channels.go b/stats/channels.go index bd9d9fb..f7317db 100644 --- a/stats/channels.go +++ b/stats/channels.go @@ -68,6 +68,7 @@ func EgressTraffic(traffic int) { } } +// GetStats returns a snapshot of Stats instance. func GetStats() Stats { rpcChan := make(chan Stats) statsChan <- rpcChan diff --git a/stats/init.go b/stats/init.go index 3fb206a..7b43a28 100644 --- a/stats/init.go +++ b/stats/init.go @@ -6,6 +6,7 @@ import ( "github.com/9seconds/mtg/config" ) +// Init initializes stats subsystem. func Init(conf *config.Config) error { if conf.StatsD.Enabled { client, err := newStatsd(conf) diff --git a/stats/stats.go b/stats/stats.go index e9c5999..686163d 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -89,6 +89,7 @@ func (s speed) MarshalJSON() ([]byte, error) { return json.Marshal(value) } +// Stats represents a statistics of the proxy. type Stats struct { URLs config.IPURLs `json:"urls"` Connections connections `json:"connections"` @@ -165,6 +166,7 @@ func (s *Stats) handleCrash() { s.Crashes++ } +// NewStats creates a new instance of Stats structure. func NewStats(conf *config.Config) *Stats { return &Stats{ URLs: conf.GetURLs(),