Files

35 lines
687 B
Go
Raw Permalink Normal View History

2023-04-19 20:10:09 +02:00
// Package source is the interface for sources
package source
import (
"errors"
"time"
)
var (
2024-02-21 10:20:36 +01:00
// ErrWatcherStopped is returned when source watcher has been stopped.
2023-04-19 20:10:09 +02:00
ErrWatcherStopped = errors.New("watcher stopped")
)
2024-02-21 10:20:36 +01:00
// Source is the source from which config is loaded.
2023-04-19 20:10:09 +02:00
type Source interface {
Read() (*ChangeSet, error)
Write(*ChangeSet) error
Watch() (Watcher, error)
String() string
}
2024-02-21 10:20:36 +01:00
// ChangeSet represents a set of changes from a source.
2023-04-19 20:10:09 +02:00
type ChangeSet struct {
2024-02-21 10:20:36 +01:00
Timestamp time.Time
2023-04-19 20:10:09 +02:00
Checksum string
Format string
Source string
2024-02-21 10:20:36 +01:00
Data []byte
2023-04-19 20:10:09 +02:00
}
2024-02-21 10:20:36 +01:00
// Watcher watches a source for changes.
2023-04-19 20:10:09 +02:00
type Watcher interface {
Next() (*ChangeSet, error)
Stop() error
}