()
| 478 | } |
| 479 | |
| 480 | func (c *chatConfigCache) cachedAdvisorConfig() (codersdk.AdvisorConfig, bool) { |
| 481 | c.mu.RLock() |
| 482 | entry := c.advisorConfig |
| 483 | c.mu.RUnlock() |
| 484 | if entry == nil { |
| 485 | return codersdk.AdvisorConfig{}, false |
| 486 | } |
| 487 | if c.clock.Now().Before(entry.expiresAt) { |
| 488 | return entry.config, true |
| 489 | } |
| 490 | |
| 491 | c.mu.Lock() |
| 492 | if current := c.advisorConfig; current != nil && !c.clock.Now().Before(current.expiresAt) { |
| 493 | c.advisorConfig = nil |
| 494 | } |
| 495 | c.mu.Unlock() |
| 496 | |
| 497 | return codersdk.AdvisorConfig{}, false |
| 498 | } |
| 499 | |
| 500 | func (c *chatConfigCache) advisorConfigGenerationSnapshot() uint64 { |
| 501 | c.mu.RLock() |
no test coverage detected