Remove unimplemented Purge and three unused interfaces (closes #73)
check / check (push) Waiting to run
check / check (push) Waiting to run
Purge only returned an error and nothing called it, so it is gone from the ImageCache interface and from Service, along with its error value. It can be added back when something needs it; eviction reclaims disk space meanwhile. The SignatureValidator, Allowlist and Storage interfaces in imgcache.go had no implementers and no users, and described types that look different from the real ones, so they are deleted. No behaviour changes. Model: opus-5-5
This commit is contained in:
@@ -29,6 +29,11 @@ P2: security: referer blacklist
|
|||||||
|
|
||||||
# Completed Steps
|
# Completed Steps
|
||||||
|
|
||||||
|
- 2026-10-04 dead code in `internal/imgcache` is gone (closes #73): `Purge`,
|
||||||
|
which only returned an error and which nothing called, is no longer part of
|
||||||
|
the `ImageCache` interface or `Service`; the `SignatureValidator`,
|
||||||
|
`Allowlist` and `Storage` interfaces, which nothing implemented or used, are
|
||||||
|
deleted. Nothing else changes.
|
||||||
- 2026-10-04 upstream host semaphores and variant `.meta` files no longer
|
- 2026-10-04 upstream host semaphores and variant `.meta` files no longer
|
||||||
outlive their use (closes #87): the fetcher counts the fetches holding or
|
outlive their use (closes #87): the fetcher counts the fetches holding or
|
||||||
waiting for a slot of each upstream host's semaphore and removes the host's
|
waiting for a slot of each upstream host's semaphore and removes the host's
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -154,9 +153,6 @@ type ImageCache interface {
|
|||||||
// Warm pre-fetches and caches an image without returning it
|
// Warm pre-fetches and caches an image without returning it
|
||||||
Warm(ctx context.Context, req *ImageRequest) error
|
Warm(ctx context.Context, req *ImageRequest) error
|
||||||
|
|
||||||
// Purge removes a cached image
|
|
||||||
Purge(ctx context.Context, req *ImageRequest) error
|
|
||||||
|
|
||||||
// Stats returns cache statistics
|
// Stats returns cache statistics
|
||||||
Stats(ctx context.Context) (*CacheStats, error)
|
Stats(ctx context.Context) (*CacheStats, error)
|
||||||
}
|
}
|
||||||
@@ -176,29 +172,3 @@ type CacheStats struct {
|
|||||||
// HitRate is HitCount / (HitCount + MissCount)
|
// HitRate is HitCount / (HitCount + MissCount)
|
||||||
HitRate float64
|
HitRate float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignatureValidator validates request signatures
|
|
||||||
type SignatureValidator interface {
|
|
||||||
// Validate checks if the signature is valid for the request
|
|
||||||
Validate(req *ImageRequest) error
|
|
||||||
// Generate creates a signature for a request
|
|
||||||
Generate(req *ImageRequest) string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allowlist checks if a URL is allowlisted (no signature required)
|
|
||||||
type Allowlist interface {
|
|
||||||
// IsAllowlisted returns true if the URL doesn't require a signature
|
|
||||||
IsAllowlisted(u *url.URL) bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Storage handles persistent storage of cached content
|
|
||||||
type Storage interface {
|
|
||||||
// Store saves content and returns its hash
|
|
||||||
Store(ctx context.Context, content io.Reader) (hash string, err error)
|
|
||||||
// Load retrieves content by hash
|
|
||||||
Load(ctx context.Context, hash string) (io.ReadCloser, error)
|
|
||||||
// Delete removes content by hash
|
|
||||||
Delete(ctx context.Context, hash string) error
|
|
||||||
// Exists checks if content exists
|
|
||||||
Exists(ctx context.Context, hash string) (bool, error)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -56,11 +56,10 @@ type ServiceConfig struct {
|
|||||||
Logger *slog.Logger
|
Logger *slog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static errors for service construction and unimplemented operations.
|
// Static errors for service construction.
|
||||||
var (
|
var (
|
||||||
errCacheRequired = errors.New("cache is required")
|
errCacheRequired = errors.New("cache is required")
|
||||||
errSigningKeyRequired = errors.New("signing key is required")
|
errSigningKeyRequired = errors.New("signing key is required")
|
||||||
errPurgeNotImplemented = errors.New("purge not implemented")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewService creates a new image service.
|
// NewService creates a new image service.
|
||||||
@@ -189,11 +188,6 @@ func (s *Service) Warm(ctx context.Context, req *ImageRequest) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Purge removes a cached image. Purging is not implemented yet.
|
|
||||||
func (s *Service) Purge(_ context.Context, _ *ImageRequest) error {
|
|
||||||
return errPurgeNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stats returns cache statistics.
|
// Stats returns cache statistics.
|
||||||
func (s *Service) Stats(ctx context.Context) (*CacheStats, error) {
|
func (s *Service) Stats(ctx context.Context) (*CacheStats, error) {
|
||||||
return s.cache.Stats(ctx)
|
return s.cache.Stats(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user