Disable stats
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2018-08-05 17:53:13 +02:00
parent f263b04661
commit aa257744f0

View File

@ -252,12 +252,12 @@ func (handler *subscriptionHandler) addSubscriberCallback(topic string, subscrib
}
func (handler *subscriptionHandler) incStat(name string) {
if v, e := handler.Stats[name]; e {
handler.Stats[name] = Stat{LastUpdate: time.Now(), Updates: v.Updates + 1}
} else {
handler.Stats[name] = Stat{LastUpdate: time.Now(), Updates: 1}
}
handler.saveStats()
// if v, e := handler.Stats[name]; e {
// handler.Stats[name] = Stat{LastUpdate: time.Now(), Updates: v.Updates + 1}
// } else {
// handler.Stats[name] = Stat{LastUpdate: time.Now(), Updates: 1}
// }
// handler.saveStats()
}
func (handler *subscriptionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@ -268,7 +268,7 @@ func (handler *subscriptionHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
enc.Encode(handler.Subscribers)
enc.Encode(handler.Stats)
//enc.Encode(handler.Stats)
}
return
}
@ -335,19 +335,20 @@ func (handler *subscriptionHandler) load() error {
if err != nil {
return err
}
return handler.loadStats()
return nil //handler.loadStats()
}
func (handler *subscriptionHandler) saveStats() error {
file, err := os.Create("./stats.json")
if err != nil {
return err
}
defer file.Close()
dec := json.NewEncoder(file)
dec.SetIndent("", " ")
err = dec.Encode(&handler.Stats)
return err
// file, err := os.Create("./stats.json")
// if err != nil {
// return err
// }
// defer file.Close()
// dec := json.NewEncoder(file)
// dec.SetIndent("", " ")
// err = dec.Encode(&handler.Stats)
// return err
return nil
}
func (handler *subscriptionHandler) saveSubscriptions() error {