1
0

source.go 683 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Package source is the interface for sources
  2. package source
  3. import (
  4. "errors"
  5. "time"
  6. )
  7. var (
  8. // ErrWatcherStopped is returned when source watcher has been stopped
  9. ErrWatcherStopped = errors.New("watcher stopped")
  10. )
  11. // Source is the source from which config is loaded
  12. type Source interface {
  13. Read() (*ChangeSet, error)
  14. Write(*ChangeSet) error
  15. Watch() (Watcher, error)
  16. String() string
  17. }
  18. // ChangeSet represents a set of changes from a source
  19. type ChangeSet struct {
  20. Data []byte
  21. Checksum string
  22. Format string
  23. Source string
  24. Timestamp time.Time
  25. }
  26. // Watcher watches a source for changes
  27. type Watcher interface {
  28. Next() (*ChangeSet, error)
  29. Stop() error
  30. }