newCooldownManager constructs a cooldownManager that reads time via now. Tests pass a fake clock so they can verify the eviction window without real wall-clock advancement.
(now func() time.Time)
| 36 | // Tests pass a fake clock so they can verify the eviction window without |
| 37 | // real wall-clock advancement. |
| 38 | func newCooldownManager(now func() time.Time) *cooldownManager { |
| 39 | if now == nil { |
| 40 | now = time.Now |
| 41 | } |
| 42 | return &cooldownManager{ |
| 43 | now: now, |
| 44 | by: make(map[string]*fallbackCooldownState), |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // Get returns the active cooldown state for agentName, or nil when no |
| 49 | // cooldown is active. Expired entries are evicted as a side-effect of the |
no outgoing calls