config.go 448 B

123456789101112131415161718192021222324252627
  1. package consumer
  2. import (
  3. "errors"
  4. )
  5. type Config struct {
  6. Hosts []string `yaml:"hosts"`
  7. Group string `yaml:"group"`
  8. Timeout int `yaml:"timeout"`
  9. }
  10. func (c Config) Invalidate() error {
  11. if len(c.Hosts) < 1 {
  12. return errors.New("at least one bootstrap server / host must be provided")
  13. }
  14. if c.Group == "" {
  15. return errors.New("group name must not be an empty string")
  16. }
  17. if c.Timeout < 1 {
  18. c.Timeout = 100
  19. }
  20. return nil
  21. }