| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package subconfigs
-
- import "fmt"
-
- // DorisConfig Doris配置
- type DorisConfig struct {
- BaseConfig
- FEHost string `yaml:"fe_host"`
- FEPort int `yaml:"fe_port"`
- FEUsername string `yaml:"fe_username"`
- FEPassword string `yaml:"fe_password"`
- MySQLHost string `yaml:"mysql_host"`
- MySQLPort int `yaml:"mysql_port"`
- MaxOpenConns int `yaml:"max_open_conns"`
- MaxIdleConns int `yaml:"max_idle_conns"`
- ConnMaxLifetime int `yaml:"conn_max_lifetime"`
- StreamLoadTimeout int `yaml:"stream_load_timeout"`
- BatchSize int `yaml:"batch_size"`
- }
-
- func NewDorisConfig() *DorisConfig {
- return &DorisConfig{}
- }
-
- func (c *DorisConfig) SetDefaults() {
- c.FEPort = 8030
- c.MySQLPort = 9030
- c.MaxOpenConns = 20
- c.MaxIdleConns = 10
- c.ConnMaxLifetime = 3600
- c.StreamLoadTimeout = 30
- c.BatchSize = 1000
- }
-
- func (c *DorisConfig) Load(data map[string]interface{}) error {
- return c.LoadFromYAML(data, c)
- }
-
- func (c *DorisConfig) Validate() error {
- if c.FEHost == "" && c.MySQLHost == "" {
- return fmt.Errorf("at least one of fe_host or mysql_host must be configured")
- }
- return nil
- }
-
- func (c *DorisConfig) IsConfigured() bool {
- return c.FEHost != "" || c.MySQLHost != ""
- }
-
- // 自动注册
- func init() {
- Register("doris", &DorisConfig{})
- }
|