config.go 440 B

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