优化结构

This commit is contained in:
Yvan
2026-08-24 17:03:46 +08:00
parent acaee94858
commit 7643152c1e
15 changed files with 244 additions and 203 deletions
+11
View File
@@ -377,6 +377,14 @@ func (d *Data) reloadConfig(ctx context.Context) error {
_ = candidateRedis.Close()
}
}()
useRedisList := useRedis && next.Admin.System.UseMultipoint
candidateRedisList := openRedisList(next.Data.RedisList, useRedisList, d.logger())
candidateRedisListAccepted := false
defer func() {
if !candidateRedisListAccepted {
closeRedisList(candidateRedisList)
}
}()
useMongo := next.Admin.System != nil && next.Admin.System.UseMongo
candidateMongo, mongoErr := openMongo(next.Data.Mongo, useMongo)
if mongoErr != nil {
@@ -410,6 +418,7 @@ func (d *Data) reloadConfig(ctx context.Context) error {
}
d.replaceDatabaseList(candidateDBList)
d.redis.replace(candidateRedis)
d.replaceRedisList(candidateRedisList)
if mongoErr == nil {
d.mongo.replace(candidateMongo)
mongoAccepted = true
@@ -417,6 +426,7 @@ func (d *Data) reloadConfig(ctx context.Context) error {
closeCandidate = false
candidateDBListAccepted = true
candidateRedisAccepted = true
candidateRedisListAccepted = true
d.runtime.Replace(next)
if d.integrations != nil {
d.integrations.Replace(integrationConfigs)
@@ -424,6 +434,7 @@ func (d *Data) reloadConfig(ctx context.Context) error {
if d.storage != nil {
d.storage.Replace(candidateStorage)
}
d.notifyResources()
return nil
}