优化结构
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user