Browse Source

Merge remote-tracking branch 'attilaolah/use-ticker'

Richard Crowley 11 năm trước cách đây
mục cha
commit
3fbdc8d6c8
1 tập tin đã thay đổi với 1 bổ sung2 xóa
  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)
 	}
 }