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