config.go 721 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dockerlogcollector
  2. import (
  3. "errors"
  4. "time"
  5. xtime "go-common/library/time"
  6. )
  7. type Config struct {
  8. ConfigEnv string `toml:"configEnv"`
  9. ConfigSuffix string `toml:"configSuffix"`
  10. MetaPath string `toml:"metaPath"`
  11. ScanInterval xtime.Duration `toml:"scanInterval"`
  12. }
  13. func (c *Config) ConfigValidate() (error) {
  14. if c == nil {
  15. return errors.New("config of docker log collector can't be nil")
  16. }
  17. if c.ConfigEnv == "" {
  18. c.ConfigEnv = "LogCollectorConf"
  19. }
  20. if c.MetaPath == "" {
  21. c.MetaPath = "/data/log-agent/meta"
  22. }
  23. if c.ConfigSuffix == "" {
  24. c.ConfigSuffix = ".conf"
  25. }
  26. if c.ScanInterval == 0 {
  27. c.ScanInterval = xtime.Duration(time.Second * 10)
  28. }
  29. return nil
  30. }