feat: implement rate limiting and caching layer for MusicBrainz provider

- Add golang.org/x/time/rate dependency for token-bucket rate limiting
- Replace custom channel-based rate limiter with rate.NewLimiter(1, 1)
- Add context.Context support to doGet for cancellation
- Add cached_at column to external_releases via migration 005
- Implement cache hit/miss queries with TTL-based filtering
- Add CacheStats type for tracking cached RGIDs
- Update ExternalRelease struct with CachedAt field
- Add rate limiting tests (1 req/sec enforcement, burst behavior)
- Add cache tests (hit, miss, expired, mixed, empty artist)
- Update migration count test for new migration
This commit is contained in:
2026-05-26 12:15:28 +03:00
parent 674daed93b
commit b0f69d3a4f
10 changed files with 518 additions and 119 deletions

View File

@@ -205,8 +205,8 @@ func TestMigrationTracking(t *testing.T) {
t.Fatalf("query migrations count: %v", err)
}
// We have 4 recorded migrations: artist_settings, external_releases, local_albums, notifications_sent.
if count != 4 {
t.Errorf("expected 4 applied migrations, got %d", count)
// We have 5 recorded migrations: artist_settings, external_releases, local_albums, notifications_sent, cached_at column.
if count != 5 {
t.Errorf("expected 5 applied migrations, got %d", count)
}
}