@@ -153,6 +153,10 @@ type Config struct {
153153 // Bind address for serving metrics.
154154 Addr string `yaml:"addr"`
155155
156+ // List of stages in a multi-level compaction.
157+ // Only includes L1 through the last non-snapshot level.
158+ Levels []* CompactionLevelConfig `yaml:"levels"`
159+
156160 // List of databases to manage.
157161 DBs []* DBConfig `yaml:"dbs"`
158162
@@ -194,6 +198,23 @@ func DefaultConfig() Config {
194198 return Config {}
195199}
196200
201+ // CompactionLevels returns a full list of compaction levels include L0.
202+ func (c * Config ) CompactionLevels () litestream.CompactionLevels {
203+ levels := litestream.CompactionLevels {
204+ {Level : 0 },
205+ }
206+
207+ for i , lvl := range c .Levels {
208+ levels = append (levels , & litestream.CompactionLevel {
209+ Level : i + 1 ,
210+ Interval : lvl .Interval ,
211+ Retention : lvl .Retention ,
212+ })
213+ }
214+
215+ return levels
216+ }
217+
197218// DBConfig returns database configuration by path.
198219func (c * Config ) DBConfig (path string ) * DBConfig {
199220 for _ , dbConfig := range c .DBs {
@@ -275,6 +296,12 @@ func ReadConfigFile(filename string, expandEnv bool) (_ Config, err error) {
275296 return config , nil
276297}
277298
299+ // CompactionLevelConfig the configuration for a single level of compaction.
300+ type CompactionLevelConfig struct {
301+ Interval time.Duration `yaml:"interval"`
302+ Retention time.Duration `yaml:"retention"`
303+ }
304+
278305// DBConfig represents the configuration for a single database.
279306type DBConfig struct {
280307 Path string `yaml:"path"`
@@ -391,7 +418,7 @@ func NewReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *litestream.Re
391418 }
392419
393420 // Build replica.
394- r := litestream .NewReplica (db , c . Name )
421+ r := litestream .NewReplica (db )
395422 if v := c .Retention ; v != nil {
396423 r .Retention = * v
397424 }
@@ -482,7 +509,7 @@ func newFileReplicaClientFromConfig(c *ReplicaConfig, r *litestream.Replica) (_
482509}
483510
484511// newS3ReplicaClientFromConfig returns a new instance of s3.ReplicaClient built from config.
485- func newS3ReplicaClientFromConfig (c * ReplicaConfig , r * litestream.Replica ) (_ * s3.ReplicaClient , err error ) {
512+ func newS3ReplicaClientFromConfig (c * ReplicaConfig , _ * litestream.Replica ) (_ * s3.ReplicaClient , err error ) {
486513 // Ensure URL & constituent parts are not both specified.
487514 if c .URL != "" && c .Path != "" {
488515 return nil , fmt .Errorf ("cannot specify url & path for s3 replica" )
@@ -545,7 +572,7 @@ func newS3ReplicaClientFromConfig(c *ReplicaConfig, r *litestream.Replica) (_ *s
545572}
546573
547574// newGCSReplicaClientFromConfig returns a new instance of gcs.ReplicaClient built from config.
548- func newGCSReplicaClientFromConfig (c * ReplicaConfig , r * litestream.Replica ) (_ * gcs.ReplicaClient , err error ) {
575+ func newGCSReplicaClientFromConfig (c * ReplicaConfig , _ * litestream.Replica ) (_ * gcs.ReplicaClient , err error ) {
549576 // Ensure URL & constituent parts are not both specified.
550577 if c .URL != "" && c .Path != "" {
551578 return nil , fmt .Errorf ("cannot specify url & path for gcs replica" )
@@ -584,7 +611,7 @@ func newGCSReplicaClientFromConfig(c *ReplicaConfig, r *litestream.Replica) (_ *
584611}
585612
586613// newABSReplicaClientFromConfig returns a new instance of abs.ReplicaClient built from config.
587- func newABSReplicaClientFromConfig (c * ReplicaConfig , r * litestream.Replica ) (_ * abs.ReplicaClient , err error ) {
614+ func newABSReplicaClientFromConfig (c * ReplicaConfig , _ * litestream.Replica ) (_ * abs.ReplicaClient , err error ) {
588615 // Ensure URL & constituent parts are not both specified.
589616 if c .URL != "" && c .Path != "" {
590617 return nil , fmt .Errorf ("cannot specify url & path for abs replica" )
@@ -627,7 +654,7 @@ func newABSReplicaClientFromConfig(c *ReplicaConfig, r *litestream.Replica) (_ *
627654}
628655
629656// newSFTPReplicaClientFromConfig returns a new instance of sftp.ReplicaClient built from config.
630- func newSFTPReplicaClientFromConfig (c * ReplicaConfig , r * litestream.Replica ) (_ * sftp.ReplicaClient , err error ) {
657+ func newSFTPReplicaClientFromConfig (c * ReplicaConfig , _ * litestream.Replica ) (_ * sftp.ReplicaClient , err error ) {
631658 // Ensure URL & constituent parts are not both specified.
632659 if c .URL != "" && c .Path != "" {
633660 return nil , fmt .Errorf ("cannot specify url & path for sftp replica" )
0 commit comments