Add retention policy, remove WAL subdir

This commit is contained in:
Ben Johnson
2021-01-11 16:49:51 -07:00
parent 1fa1313b0b
commit faa5765745
4 changed files with 240 additions and 152 deletions

View File

@@ -10,6 +10,7 @@ import (
"os/user"
"path/filepath"
"strings"
"time"
"github.com/benbjohnson/litestream"
"gopkg.in/yaml.v2"
@@ -155,9 +156,10 @@ type DBConfig struct {
}
type ReplicaConfig struct {
Type string `yaml:"type"` // "file", "s3"
Name string `yaml:"name"` // name of replica, optional.
Path string `yaml:"path"` // used for file replicas
Type string `yaml:"type"` // "file", "s3"
Name string `yaml:"name"` // name of replica, optional.
Path string `yaml:"path"`
Retention time.Duration `yaml:"retention"`
}
func registerConfigFlag(fs *flag.FlagSet, p *string) {
@@ -196,5 +198,9 @@ func newFileReplicaFromConfig(db *litestream.DB, config *ReplicaConfig) (*litest
if config.Path == "" {
return nil, fmt.Errorf("file replica path require for db %q", db.Path())
}
return litestream.NewFileReplica(db, config.Name, config.Path), nil
r := litestream.NewFileReplica(db, config.Name, config.Path)
if v := config.Retention; v > 0 {
r.RetentionInterval = v
}
return r, nil
}