Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

doris_config.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package subconfigs
  2. import "fmt"
  3. // DorisConfig Doris配置
  4. type DorisConfig struct {
  5. BaseConfig
  6. FEHost string `yaml:"fe_host"`
  7. FEPort int `yaml:"fe_port"`
  8. FEUsername string `yaml:"fe_username"`
  9. FEPassword string `yaml:"fe_password"`
  10. MySQLHost string `yaml:"mysql_host"`
  11. MySQLPort int `yaml:"mysql_port"`
  12. MaxOpenConns int `yaml:"max_open_conns"`
  13. MaxIdleConns int `yaml:"max_idle_conns"`
  14. ConnMaxLifetime int `yaml:"conn_max_lifetime"`
  15. StreamLoadTimeout int `yaml:"stream_load_timeout"`
  16. BatchSize int `yaml:"batch_size"`
  17. }
  18. func NewDorisConfig() *DorisConfig {
  19. return &DorisConfig{}
  20. }
  21. func (c *DorisConfig) SetDefaults() {
  22. c.FEPort = 8030
  23. c.MySQLPort = 9030
  24. c.MaxOpenConns = 20
  25. c.MaxIdleConns = 10
  26. c.ConnMaxLifetime = 3600
  27. c.StreamLoadTimeout = 30
  28. c.BatchSize = 1000
  29. }
  30. func (c *DorisConfig) Load(data map[string]interface{}) error {
  31. return c.LoadFromYAML(data, c)
  32. }
  33. func (c *DorisConfig) Validate() error {
  34. if c.FEHost == "" && c.MySQLHost == "" {
  35. return fmt.Errorf("at least one of fe_host or mysql_host must be configured")
  36. }
  37. return nil
  38. }
  39. func (c *DorisConfig) IsConfigured() bool {
  40. return c.FEHost != "" || c.MySQLHost != ""
  41. }
  42. // 自动注册
  43. func init() {
  44. Register("doris", &DorisConfig{})
  45. }