noop.go 444 B

12345678910111213141516171819202122232425
  1. package source
  2. import (
  3. "errors"
  4. )
  5. type noopWatcher struct {
  6. exit chan struct{}
  7. }
  8. func (w *noopWatcher) Next() (*ChangeSet, error) {
  9. <-w.exit
  10. return nil, errors.New("noopWatcher stopped")
  11. }
  12. func (w *noopWatcher) Stop() error {
  13. close(w.exit)
  14. return nil
  15. }
  16. // NewNoopWatcher returns a watcher that blocks on Next() until Stop() is called.
  17. func NewNoopWatcher() (Watcher, error) {
  18. return &noopWatcher{exit: make(chan struct{})}, nil
  19. }