core: add jikan stale retry pipeline

This commit is contained in:
2026-04-12 14:53:32 +02:00
parent f5d13165f4
commit eda055fea3
7 changed files with 325 additions and 20 deletions

View File

@@ -34,9 +34,19 @@ func (c *Client) GetRecommendations(ctx context.Context, animeID int, limit int)
return cached, nil
}
var stale []Anime
hasStale := c.getStaleCache(ctx, cacheKey, &stale)
var result RecommendationsResponse
reqURL := fmt.Sprintf("%s/anime/%d/recommendations", c.baseURL, animeID)
if err := c.fetchWithRetry(ctx, reqURL, &result); err != nil {
if hasStale {
if limit > 0 && len(stale) > limit {
return stale[:limit], nil
}
return stale, nil
}
return nil, err
}