Next returns the resolved address update(delta) for the target. If there's no change, it will sleep for 30 mins and try to resolve again after that.
()
| 252 | // Next returns the resolved address update(delta) for the target. If there's no |
| 253 | // change, it will sleep for 30 mins and try to resolve again after that. |
| 254 | func (w *dnsWatcher) Next() ([]*Update, error) { |
| 255 | for { |
| 256 | select { |
| 257 | case <-w.ctx.Done(): |
| 258 | return nil, errWatcherClose |
| 259 | case <-w.t.C: |
| 260 | } |
| 261 | result := w.lookup() |
| 262 | // Next lookup should happen after an interval defined by w.r.freq. |
| 263 | w.t.Reset(w.r.freq) |
| 264 | if len(result) > 0 { |
| 265 | return result, nil |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | func (w *dnsWatcher) Close() { |
| 271 | w.cancel() |