From aa257744f02d78580875de0fd99af4dc98995dfb Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sun, 5 Aug 2018 17:53:13 +0200 Subject: [PATCH] Disable stats --- cmd/hubserver/main.go | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/cmd/hubserver/main.go b/cmd/hubserver/main.go index 39cf262..434b03a 100644 --- a/cmd/hubserver/main.go +++ b/cmd/hubserver/main.go @@ -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 {