MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / StartAutoRefresh

Method StartAutoRefresh

sdk/cliproxy/auth/conductor.go:5239–5267  ·  view source on GitHub ↗

StartAutoRefresh launches a background loop that evaluates auth freshness every few seconds and triggers refresh operations when required. Only one loop is kept alive; starting a new one cancels the previous run.

(parent context.Context, interval time.Duration)

Source from the content-addressed store, hash-verified

5237// every few seconds and triggers refresh operations when required.
5238// Only one loop is kept alive; starting a new one cancels the previous run.
5239func (m *Manager) StartAutoRefresh(parent context.Context, interval time.Duration) {
5240 if interval <= 0 {
5241 interval = refreshCheckInterval
5242 }
5243
5244 m.mu.Lock()
5245 cancelPrev := m.refreshCancel
5246 m.refreshCancel = nil
5247 m.refreshLoop = nil
5248 m.mu.Unlock()
5249 if cancelPrev != nil {
5250 cancelPrev()
5251 }
5252
5253 ctx, cancelCtx := context.WithCancel(parent)
5254 workers := refreshMaxConcurrency
5255 if cfg, ok := m.runtimeConfig.Load().(*internalconfig.Config); ok && cfg != nil && cfg.AuthAutoRefreshWorkers > 0 {
5256 workers = cfg.AuthAutoRefreshWorkers
5257 }
5258 loop := newAuthAutoRefreshLoop(m, interval, workers)
5259
5260 m.mu.Lock()
5261 m.refreshCancel = cancelCtx
5262 m.refreshLoop = loop
5263 m.mu.Unlock()
5264
5265 loop.rebuild(time.Now())
5266 go loop.run(ctx)
5267}
5268
5269// StopAutoRefresh cancels the background refresh loop, if running.
5270// It also stops the selector if it implements StoppableSelector.

Callers 1

RunMethod · 0.80

Calls 4

newAuthAutoRefreshLoopFunction · 0.85
LoadMethod · 0.65
rebuildMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected