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,7 +991,9 @@ 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.
ampConfigChanged := oldCfg == nil || !reflect.DeepEqual(oldCfg.AmpCode, cfg.AmpCode)
if ampConfigChanged {
if s.ampModule != nil { if s.ampModule != nil {
log.Debugf("triggering amp module config update") log.Debugf("triggering amp module config update")
if err := s.ampModule.OnConfigUpdated(cfg); err != nil { if err := s.ampModule.OnConfigUpdated(cfg); err != nil {
@@ -999,6 +1002,7 @@ func (s *Server) UpdateClients(cfg *config.Config) {
} else { } else {
log.Warnf("amp module is nil, skipping config update") 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.
tokenStore := sdkAuth.GetTokenStore() tokenStore := sdkAuth.GetTokenStore()