Rename replicator config to replica
This commit is contained in:
@@ -49,10 +49,10 @@ func ReadConfigFile(filename string) (Config, error) {
|
|||||||
|
|
||||||
type DBConfig struct {
|
type DBConfig struct {
|
||||||
Path string `yaml:"path"`
|
Path string `yaml:"path"`
|
||||||
Replicators []*ReplicatorConfig `yaml:"replicators`
|
Replicas []*ReplicaConfig `yaml:"replicas"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReplicatorConfig struct {
|
type ReplicaConfig struct {
|
||||||
Type string `yaml:"type"` // "file", "s3"
|
Type string `yaml:"type"` // "file", "s3"
|
||||||
Name string `yaml:"name"` // name of replicator, optional.
|
Name string `yaml:"name"` // name of replicator, optional.
|
||||||
Path string `yaml:"path"` // used for file replicators
|
Path string `yaml:"path"` // used for file replicators
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func (m *Main) openDB(config *DBConfig) error {
|
|||||||
db := litestream.NewDB(config.Path)
|
db := litestream.NewDB(config.Path)
|
||||||
|
|
||||||
// Instantiate and attach replicators.
|
// Instantiate and attach replicators.
|
||||||
for _, rconfig := range config.Replicators {
|
for _, rconfig := range config.Replicas {
|
||||||
r, err := m.createReplicator(db, rconfig)
|
r, err := m.createReplicator(db, rconfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -135,7 +135,7 @@ func (m *Main) openDB(config *DBConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createReplicator instantiates a replicator for a DB based on a config.
|
// createReplicator instantiates a replicator for a DB based on a config.
|
||||||
func (m *Main) createReplicator(db *litestream.DB, config *ReplicatorConfig) (litestream.Replicator, error) {
|
func (m *Main) createReplicator(db *litestream.DB, config *ReplicaConfig) (litestream.Replicator, error) {
|
||||||
switch config.Type {
|
switch config.Type {
|
||||||
case "", "file":
|
case "", "file":
|
||||||
return m.createFileReplicator(db, config)
|
return m.createFileReplicator(db, config)
|
||||||
@@ -145,7 +145,7 @@ func (m *Main) createReplicator(db *litestream.DB, config *ReplicatorConfig) (li
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createFileReplicator returns a new instance of FileReplicator build from config.
|
// createFileReplicator returns a new instance of FileReplicator build from config.
|
||||||
func (m *Main) createFileReplicator(db *litestream.DB, config *ReplicatorConfig) (*litestream.FileReplicator, error) {
|
func (m *Main) createFileReplicator(db *litestream.DB, config *ReplicaConfig) (*litestream.FileReplicator, error) {
|
||||||
if config.Path == "" {
|
if config.Path == "" {
|
||||||
return nil, fmt.Errorf("file replicator path require for db %q", db.Path())
|
return nil, fmt.Errorf("file replicator path require for db %q", db.Path())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user