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

@@ -13,9 +13,16 @@ func (c *Client) GetAnimeByID(ctx context.Context, id int) (Anime, error) {
return cached, nil
}
var stale Anime
hasStale := c.getStaleCache(ctx, cacheKey, &stale)
var result AnimeResponse
reqURL := fmt.Sprintf("%s/anime/%d/full", c.baseURL, id)
if err := c.fetchWithRetry(ctx, reqURL, &result); err != nil {
if hasStale {
return stale, nil
}
return Anime{}, err
}