优化结构
This commit is contained in:
@@ -303,7 +303,7 @@ func (d *Data) reloadConfig(ctx context.Context) error {
|
||||
if configPath == "" {
|
||||
return fmt.Errorf("configuration path is not set")
|
||||
}
|
||||
next, err := readBootstrap(configPath)
|
||||
next, err := config.Load(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -406,7 +406,7 @@ func (d *Data) reloadConfig(ctx context.Context) error {
|
||||
closeDatabaseList(candidateDBList)
|
||||
}
|
||||
}()
|
||||
integrationConfigs, err := readIntegrationRuntime(candidateDB)
|
||||
integrationConfigs, err := readIntegrationRuntime(candidateDB.WithContext(ctx))
|
||||
if err != nil {
|
||||
return fmt.Errorf("reload integration runtime: %w", err)
|
||||
}
|
||||
@@ -417,8 +417,20 @@ func (d *Data) reloadConfig(ctx context.Context) error {
|
||||
registerDataScopeCallbacks(item, d.enqueueDataScopeAudit)
|
||||
}
|
||||
d.replaceDatabaseList(candidateDBList)
|
||||
d.redis.replace(candidateRedis)
|
||||
d.replaceRedisList(candidateRedisList)
|
||||
// openRedis and openRedisList return nil when a ping fails, so replacing
|
||||
// unconditionally would let a transient Redis outage during an unrelated
|
||||
// configuration reload retire the still-healthy clients and silently downgrade
|
||||
// the process to the in-memory cache until the next reload.
|
||||
if candidateRedis != nil || !useRedis || !redisConnectionConfigured(next.Data.Redis) {
|
||||
d.redis.replace(candidateRedis)
|
||||
} else {
|
||||
d.logger().Warn("keeping the previous redis client because the reloaded configuration failed to connect", "mod", "redis")
|
||||
}
|
||||
if candidateRedisList != nil || !useRedisList || len(next.Data.RedisList) == 0 {
|
||||
d.replaceRedisList(candidateRedisList)
|
||||
} else {
|
||||
d.logger().Warn("keeping the previous redis list because the reloaded configuration failed to connect", "mod", "redis")
|
||||
}
|
||||
if mongoErr == nil {
|
||||
d.mongo.replace(candidateMongo)
|
||||
mongoAccepted = true
|
||||
@@ -437,7 +449,3 @@ func (d *Data) reloadConfig(ctx context.Context) error {
|
||||
d.notifyResources()
|
||||
return nil
|
||||
}
|
||||
|
||||
func readBootstrap(configPath string) (*config.Config, error) {
|
||||
return config.Load(configPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user