github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/worker/pruner/config.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package pruner 5 6 import ( 7 "time" 8 9 "github.com/juju/clock" 10 "github.com/juju/errors" 11 ) 12 13 // Logger defines the methods used by the pruner worker for logging. 14 type Logger interface { 15 Infof(string, ...interface{}) 16 } 17 18 // Config holds all necessary attributes to start a pruner worker. 19 type Config struct { 20 Facade Facade 21 PruneInterval time.Duration 22 Clock clock.Clock 23 Logger Logger 24 } 25 26 // Validate will err unless basic requirements for a valid 27 // config are met. 28 func (c *Config) Validate() error { 29 if c.Facade == nil { 30 return errors.New("missing Facade") 31 } 32 if c.Clock == nil { 33 return errors.New("missing Clock") 34 } 35 if c.Logger == nil { 36 return errors.New("missing Logger") 37 } 38 return nil 39 } 40 41 // New returns a worker.Worker for history Pruner. 42 func New(conf Config) PrunerWorker { 43 return PrunerWorker{ 44 config: conf, 45 } 46 }