瀏覽代碼

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)
 	}
 }