CheckAndStoreEvery calls CheckAndStore every interval. It returns the ticker that it's using so you can stop it when you don't want it to run anymore. This function does NOT block (it runs the ticker in a goroutine). Any errors are written to the standard logger. It would not be wise to set an inter
(interval time.Duration)
| 126 | // would not be wise to set an interval lower than the time it takes |
| 127 | // to perform the checks. |
| 128 | func (c Checkup) CheckAndStoreEvery(interval time.Duration) *time.Ticker { |
| 129 | ticker := time.NewTicker(interval) |
| 130 | go func() { |
| 131 | for range ticker.C { |
| 132 | if err := c.CheckAndStore(); err != nil { |
| 133 | log.Println(err) |
| 134 | } |
| 135 | } |
| 136 | }() |
| 137 | return ticker |
| 138 | } |
| 139 | |
| 140 | // MarshalJSON marshals c into JSON with type information |
| 141 | // included on the interface values. |