()
| 40 | } |
| 41 | |
| 42 | func (s *Instancer) loop() { |
| 43 | ch := make(chan struct{}) |
| 44 | go s.client.WatchPrefix(s.prefix, ch) |
| 45 | for { |
| 46 | select { |
| 47 | case <-ch: |
| 48 | instances, err := s.client.GetEntries(s.prefix) |
| 49 | if err != nil { |
| 50 | s.logger.Log("msg", "failed to retrieve entries", "err", err) |
| 51 | s.cache.Update(sd.Event{Err: err}) |
| 52 | continue |
| 53 | } |
| 54 | s.cache.Update(sd.Event{Instances: instances}) |
| 55 | |
| 56 | case <-s.quitc: |
| 57 | return |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Stop terminates the Instancer. |
| 63 | func (s *Instancer) Stop() { |
no test coverage detected