| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package subconfigs
-
- import (
- "fmt"
-
- "git.x2erp.com/qdy/go-base/config/core"
- )
-
- type DorisConfig struct {
- core.BaseConfig
- FEHost string `yaml:"fe_host" desc:"Doris FE节点主机地址"`
- FEPort int `yaml:"fe_port" desc:"Doris FE节点端口"`
- FEUsername string `yaml:"fe_username" desc:"Doris FE节点用户名"`
- FEPassword string `yaml:"fe_password" desc:"Doris FE节点密码"`
- MySQLHost string `yaml:"mysql_host" desc:"MySQL兼容接口主机地址"`
- MySQLPort int `yaml:"mysql_port" desc:"MySQL兼容接口端口"`
- MaxOpenConns int `yaml:"max_open_conns" desc:"最大打开连接数"`
- MaxIdleConns int `yaml:"max_idle_conns" desc:"最大空闲连接数"`
- ConnMaxLifetime int `yaml:"conn_max_lifetime" desc:"连接最大生命周期(秒)"`
- StreamLoadTimeout int `yaml:"stream_load_timeout" desc:"Stream Load超时时间(秒)"`
- BatchSize int `yaml:"batch_size" desc:"批量操作大小"`
- }
-
- func (c *DorisConfig) Description() string {
- return "Doris数据库连接配置"
- }
-
- 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() {
- core.Register("doris", &DorisConfig{})
- }
|