(newCfg *config.Config, synthesizeConfigAuths bool)
| 1245 | } |
| 1246 | |
| 1247 | func (s *Service) applyConfigUpdateWithAuthSynthesis(newCfg *config.Config, synthesizeConfigAuths bool) { |
| 1248 | if s == nil { |
| 1249 | return |
| 1250 | } |
| 1251 | |
| 1252 | s.configUpdateMu.Lock() |
| 1253 | defer s.configUpdateMu.Unlock() |
| 1254 | |
| 1255 | previousStrategy := "" |
| 1256 | var previousSessionAffinity bool |
| 1257 | var previousSessionAffinityTTL string |
| 1258 | s.cfgMu.RLock() |
| 1259 | if s.cfg != nil { |
| 1260 | previousStrategy = strings.ToLower(strings.TrimSpace(s.cfg.Routing.Strategy)) |
| 1261 | previousSessionAffinity = s.cfg.Routing.SessionAffinity |
| 1262 | previousSessionAffinityTTL = s.cfg.Routing.SessionAffinityTTL |
| 1263 | } |
| 1264 | s.cfgMu.RUnlock() |
| 1265 | |
| 1266 | if newCfg == nil { |
| 1267 | s.cfgMu.RLock() |
| 1268 | newCfg = s.cfg |
| 1269 | s.cfgMu.RUnlock() |
| 1270 | } |
| 1271 | if newCfg == nil { |
| 1272 | return |
| 1273 | } |
| 1274 | |
| 1275 | nextStrategy := strings.ToLower(strings.TrimSpace(newCfg.Routing.Strategy)) |
| 1276 | normalizeStrategy := func(strategy string) string { |
| 1277 | switch strategy { |
| 1278 | case "fill-first", "fillfirst", "ff": |
| 1279 | return "fill-first" |
| 1280 | default: |
| 1281 | return "round-robin" |
| 1282 | } |
| 1283 | } |
| 1284 | previousStrategy = normalizeStrategy(previousStrategy) |
| 1285 | nextStrategy = normalizeStrategy(nextStrategy) |
| 1286 | |
| 1287 | nextSessionAffinity := newCfg.Routing.SessionAffinity |
| 1288 | nextSessionAffinityTTL := newCfg.Routing.SessionAffinityTTL |
| 1289 | |
| 1290 | selectorChanged := previousStrategy != nextStrategy || |
| 1291 | previousSessionAffinity != nextSessionAffinity || |
| 1292 | previousSessionAffinityTTL != nextSessionAffinityTTL |
| 1293 | |
| 1294 | if s.coreManager != nil && selectorChanged { |
| 1295 | var selector coreauth.Selector |
| 1296 | switch nextStrategy { |
| 1297 | case "fill-first": |
| 1298 | selector = &coreauth.FillFirstSelector{} |
| 1299 | default: |
| 1300 | selector = &coreauth.RoundRobinSelector{} |
| 1301 | } |
| 1302 | |
| 1303 | if nextSessionAffinity { |
| 1304 | ttl := time.Hour |
no test coverage detected