2019-05-31 01:11:13 +03:00
|
|
|
// Package source is the interface for sources
|
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
2019-08-21 00:32:47 +03:00
|
|
|
"errors"
|
2019-05-31 01:11:13 +03:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2019-08-21 00:32:47 +03:00
|
|
|
var (
|
|
|
|
// ErrWatcherStopped is returned when source watcher has been stopped
|
|
|
|
ErrWatcherStopped = errors.New("watcher stopped")
|
|
|
|
)
|
|
|
|
|
2019-05-31 01:11:13 +03:00
|
|
|
// Source is the source from which config is loaded
|
|
|
|
type Source interface {
|
|
|
|
Read() (*ChangeSet, error)
|
|
|
|
Watch() (Watcher, error)
|
2019-12-23 11:42:57 +03:00
|
|
|
Write(*ChangeSet) error
|
2019-05-31 01:11:13 +03:00
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChangeSet represents a set of changes from a source
|
|
|
|
type ChangeSet struct {
|
|
|
|
Data []byte
|
|
|
|
Checksum string
|
|
|
|
Format string
|
|
|
|
Source string
|
|
|
|
Timestamp time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// Watcher watches a source for changes
|
|
|
|
type Watcher interface {
|
|
|
|
Next() (*ChangeSet, error)
|
|
|
|
Stop() error
|
|
|
|
}
|