|
|
@@ -16,6 +16,18 @@ type Config struct {
|
|
16
|
16
|
Doris DorisConfig `yaml:"doris"`
|
|
17
|
17
|
Auth Auth `yaml:"auth"`
|
|
18
|
18
|
Service Service `yaml:"service"`
|
|
|
19
|
+ HTTP HTTPConfig `yaml:"http"` // 新增 HTTP 配置
|
|
|
20
|
+}
|
|
|
21
|
+
|
|
|
22
|
+// HTTPConfig HTTP客户端配置
|
|
|
23
|
+type HTTPConfig struct {
|
|
|
24
|
+ Timeout int `yaml:"timeout"` // 请求超时时间(秒)
|
|
|
25
|
+ MaxIdleConns int `yaml:"max_idle_conns"` // 最大空闲连接数
|
|
|
26
|
+ MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host"` // 每个主机的最大空闲连接数
|
|
|
27
|
+ IdleConnTimeout int `yaml:"idle_conn_timeout"` // 空闲连接超时时间(秒)
|
|
|
28
|
+ MaxConnsPerHost int `yaml:"max_conns_per_host"` // 每个主机的最大连接数
|
|
|
29
|
+ DisableCompression bool `yaml:"disable_compression"` // 是否禁用压缩
|
|
|
30
|
+ DisableKeepAlives bool `yaml:"disable_keep_alives"` // 是否禁用长连接
|
|
19
|
31
|
}
|
|
20
|
32
|
|
|
21
|
33
|
// DBConfig 数据库配置
|
|
|
@@ -91,9 +103,11 @@ type IConfig interface {
|
|
91
|
103
|
GetDoris() DorisConfig
|
|
92
|
104
|
GetAuth() Auth
|
|
93
|
105
|
GetService() Service
|
|
|
106
|
+ GetHTTP() HTTPConfig // 新增获取HTTP配置方法
|
|
94
|
107
|
IsDatabaseConfigured() bool
|
|
95
|
108
|
IsRedisConfigured() bool
|
|
96
|
109
|
IsDorisConfigured() bool
|
|
|
110
|
+ IsHTTPConfigured() bool // 新增检查HTTP配置方法
|
|
97
|
111
|
}
|
|
98
|
112
|
|
|
99
|
113
|
// 实现接口的具体类型
|
|
|
@@ -121,6 +135,10 @@ func (cw *configWrapper) GetService() Service {
|
|
121
|
135
|
return cw.config.Service
|
|
122
|
136
|
}
|
|
123
|
137
|
|
|
|
138
|
+func (cw *configWrapper) GetHTTP() HTTPConfig {
|
|
|
139
|
+ return cw.config.HTTP
|
|
|
140
|
+}
|
|
|
141
|
+
|
|
124
|
142
|
func (cw *configWrapper) IsDatabaseConfigured() bool {
|
|
125
|
143
|
db := cw.config.Database
|
|
126
|
144
|
return db.Type != "" &&
|
|
|
@@ -141,6 +159,11 @@ func (cw *configWrapper) IsDorisConfigured() bool {
|
|
141
|
159
|
return doris.FEHost != "" && doris.FEPort > 0
|
|
142
|
160
|
}
|
|
143
|
161
|
|
|
|
162
|
+func (cw *configWrapper) IsHTTPConfigured() bool {
|
|
|
163
|
+ httpCfg := cw.config.HTTP
|
|
|
164
|
+ return httpCfg.Timeout > 0
|
|
|
165
|
+}
|
|
|
166
|
+
|
|
144
|
167
|
func (cw *configWrapper) IsAuthConfigured() bool {
|
|
145
|
168
|
return cw.config.Auth.Token != ""
|
|
146
|
169
|
}
|
|
|
@@ -210,6 +233,15 @@ func loadConfig() (*Config, error) {
|
|
210
|
233
|
StreamLoadTimeout: 30,
|
|
211
|
234
|
BatchSize: 1000,
|
|
212
|
235
|
},
|
|
|
236
|
+ HTTP: HTTPConfig{
|
|
|
237
|
+ Timeout: 30,
|
|
|
238
|
+ MaxIdleConns: 100,
|
|
|
239
|
+ MaxIdleConnsPerHost: 10,
|
|
|
240
|
+ IdleConnTimeout: 90,
|
|
|
241
|
+ MaxConnsPerHost: 0, // 0表示不限制
|
|
|
242
|
+ DisableCompression: false,
|
|
|
243
|
+ DisableKeepAlives: false,
|
|
|
244
|
+ },
|
|
213
|
245
|
}
|
|
214
|
246
|
// 读取配置文件
|
|
215
|
247
|
data, err := os.ReadFile(configFile)
|