config.go 442 B

123456789101112131415161718192021222324252627
  1. package kafka
  2. import (
  3. "fmt"
  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 fmt.Errorf("at least one bootstrap server / host must be provided")
  13. }
  14. if c.Group == "" {
  15. return fmt.Errorf("group name must not be an empty string")
  16. }
  17. if c.Timeout < 1 {
  18. c.Timeout = 100
  19. }
  20. return nil
  21. }