Преглед изворни кода

use a time.Ticker instead of the time.Sleep

Attila Oláh пре 11 година
родитељ
комит
f47ededb99
1 измењених фајлова са 1 додато и 2 уклоњено
  1. 1 2
      json.go

+ 1 - 2
json.go

@@ -71,9 +71,8 @@ func (r StandardRegistry) MarshalJSON() ([]byte, error) {
 // WriteJSON writes metrics from the given registry  periodically to the
 // specified io.Writer as JSON.
 func WriteJSON(r Registry, d time.Duration, w io.Writer) {
-	for {
+	for _ = range time.Tick(d) {
 		WriteJSONOnce(r, w)
-		time.Sleep(d)
 	}
 }