Split internal/imgcache into the image proxy and the cache (closes #317)
check / check (push) Canceled after 0s

The new package internal/imageproxy holds Proxy, which was imgcache.Service,
with its Config, ImageResponse, CacheStatus and errors. NewProxy makes and
registers the counters of upstream fetches and transforms. internal/imgcache
holds the cache only, with its hit and miss counters, and imgcache.CacheConfig
is imgcache.Config. The cache reads and writes each kind it keeps with one pair
of methods: Variant and PutVariant, Source and PutSource, Failure and
PutFailure. Source replaces LookupSource followed by GetSourceContent.
imgcache.go and module.go are gone. The proxy's tests moved with it. The
cache's tests check that the reconciliation pass removes an empty or cut file
and its row. The proxy's tests remove them by hand, then check that Get fetches
or converts again.

Model: opus-5-5
This commit is contained in:
2026-10-26 18:39:15 +00:00
committed by sneak
parent 87cb1ab5f6
commit ce4df5077b
38 changed files with 1474 additions and 1113 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ func TestCache_CleanExpired(t *testing.T) {
tmpDir := t.TempDir()
db := setupTestDB(t)
cache, _ := NewCache(db, CacheConfig{
cache, _ := NewCache(db, Config{
StateDir: tmpDir,
NegativeTTL: 1 * time.Millisecond,
MaxBytes: 1 << 30,
@@ -103,7 +103,7 @@ func TestCache_StorageDirectoriesCreated(t *testing.T) {
tmpDir := t.TempDir()
db := setupTestDB(t)
_, err := NewCache(db, CacheConfig{
_, err := NewCache(db, Config{
StateDir: tmpDir,
MaxBytes: 1 << 30,
}, prometheus.NewRegistry())