fix(api): update amp module only on config changes

This commit is contained in:
hkfires
2026-01-29 09:28:49 +08:00
parent 9e5b1d24e8
commit 8510fc313e

View File

@@ -12,6 +12,7 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"reflect"
"strings" "strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
@@ -990,14 +991,17 @@ func (s *Server) UpdateClients(cfg *config.Config) {
s.mgmt.SetAuthManager(s.handlers.AuthManager) s.mgmt.SetAuthManager(s.handlers.AuthManager)
} }
// Notify Amp module of config changes (for model mapping hot-reload) // Notify Amp module only when Amp config has changed.
if s.ampModule != nil { ampConfigChanged := oldCfg == nil || !reflect.DeepEqual(oldCfg.AmpCode, cfg.AmpCode)
log.Debugf("triggering amp module config update") if ampConfigChanged {
if err := s.ampModule.OnConfigUpdated(cfg); err != nil { if s.ampModule != nil {
log.Errorf("failed to update Amp module config: %v", err) log.Debugf("triggering amp module config update")
if err := s.ampModule.OnConfigUpdated(cfg); err != nil {
log.Errorf("failed to update Amp module config: %v", err)
}
} else {
log.Warnf("amp module is nil, skipping config update")
} }
} else {
log.Warnf("amp module is nil, skipping config update")
} }
// Count client sources from configuration and auth store. // Count client sources from configuration and auth store.