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