watcher.go 376 B

1234567891011121314151617181920212223
  1. package memory
  2. import (
  3. "gogs.baozhida.cn/zoie/OAuth-core/config/source"
  4. )
  5. type watcher struct {
  6. Id string
  7. Updates chan *source.ChangeSet
  8. Source *memory
  9. }
  10. func (w *watcher) Next() (*source.ChangeSet, error) {
  11. cs := <-w.Updates
  12. return cs, nil
  13. }
  14. func (w *watcher) Stop() error {
  15. w.Source.Lock()
  16. delete(w.Source.Watchers, w.Id)
  17. w.Source.Unlock()
  18. return nil
  19. }