refactor(providers): one paced, retrying HTTP client for cover art and tags (#8002)

coverart/httpclient.go and tags/httpclient.go were the same client:
pacing, exponential backoff with jitter, 401/403-as-transient, body
caps. Tags had added a User-Agent and a shared Pacer, cover art an image
GET. providers.HTTPClient now has all of it, with the tests that were in
coverart. ErrTransient is shared too, so both families' errors.Is still
match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 12:58:55 -05:00
co-authored by Claude Opus 5.5
parent 487e11f59f
commit b901560edf
16 changed files with 333 additions and 471 deletions
@@ -10,6 +10,8 @@ import (
"sync/atomic"
"testing"
"time"
"git.fabledsword.com/bvandeusen/minstrel/internal/providers"
)
// withTheAudioDBBaseURL temporarily redirects theAudioDBBaseURL to a
@@ -28,7 +30,7 @@ func newTheAudioDBProviderForTest(t *testing.T, mockURL string) *theAudioDBProvi
withTheAudioDBBaseURL(t, mockURL)
p := &theAudioDBProvider{
client: newHTTPClient(httpClientOptions{Name: "theaudiodb", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond}),
client: providers.NewHTTPClient(providers.HTTPOptions{Name: "theaudiodb", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond}),
}
Register(p)
p.enabled.Store(true)
@@ -234,7 +236,7 @@ func TestTheAudioDB_DefaultsToTestKeyOnEmpty(t *testing.T) {
defer resetRegistryForTests()
withTheAudioDBBaseURL(t, srv.URL)
p := &theAudioDBProvider{client: newHTTPClient(httpClientOptions{Name: "theaudiodb", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})}
p := &theAudioDBProvider{client: providers.NewHTTPClient(providers.HTTPOptions{Name: "theaudiodb", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})}
Register(p)
// Configure with empty key — should fall back to test key.
if err := p.Configure(ProviderSettings{Enabled: true, APIKey: ""}); err != nil {