diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-19 08:15:28 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-19 08:15:28 +0300 |
| commit | 682a413db516e1a0201e8fea41e706a7666391d6 (patch) | |
| tree | 614566bce20aacd4935aa81fd9c49aca523a2113 /internal/hexaicli | |
| parent | a80ad2b4691d0df63f68c6977ee18444e7bb752f (diff) | |
ik0 remove mutable clock holders
Diffstat (limited to 'internal/hexaicli')
| -rw-r--r-- | internal/hexaicli/cache.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/internal/hexaicli/cache.go b/internal/hexaicli/cache.go index 742ffce..127c7f4 100644 --- a/internal/hexaicli/cache.go +++ b/internal/hexaicli/cache.go @@ -17,17 +17,12 @@ const cliResponseCacheTTL = 24 * time.Hour // responseCache carries the injectable dependencies for the on-disk CLI // response cache. The only dependency is the clock used to stamp entries and -// decide expiry. Production code uses defaultResponseCache (backed by -// time.Now); tests construct a responseCache with a fake clock to exercise TTL -// expiry without sleeping. +// decide expiry. Production wrappers construct it with time.Now; tests can use +// a fake clock to exercise TTL expiry without sleeping. type responseCache struct { now func() time.Time } -// defaultResponseCache is the production cache used by the package-level -// lookup/store wrappers. It reads the real wall clock. -var defaultResponseCache = responseCache{now: time.Now} - // cacheNowContextKey carries an injected clock through the request context so // the cache TTL logic can be driven deterministically (e.g. in tests) without // mutating package state. @@ -45,7 +40,7 @@ func responseCacheFromContext(ctx context.Context) responseCache { if now, ok := ctx.Value(cacheNowContextKey{}).(func() time.Time); ok && now != nil { return responseCache{now: now} } - return defaultResponseCache + return responseCache{now: time.Now} } type cliResponseCacheKey struct { |
