Skip to content

Issue 43 Caching Market API calls - AdSlot & AdUnits #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

elpiel
Copy link
Member

@elpiel elpiel commented Feb 4, 2021

Resolves #43

CHANGELOG:

  • MarketApi is now wrapped in an Arc for cheap cloning

  • Generic Cache implementation for caching records for /units-for-slot route

    • Implementations for the generic Cache (mod supermarket::cache::market), caching the following calls:
      • GET AdSlot from Market - mod supermarket::cache::market::ad_slot

        • type AdSlotCache = Cache
        • impl ClientLike for AdSlotClient with calls via the MarketApi
      • GET AdUnit from Market (AdSlot's fallback unit) - mod supermarket::cache::market::ad_unit

        • type AdUnitsCache = Cache
        • impl ClientLike for AdUnitsClient with calls via the MarketApi
      • GET AdUnits (fetched by Ad Type from the Market) - mod supermarket::cache::market::ad_unit type AdTypeCache

        • type AdTypeCache = Cache
        • impl ClientLike for AdTypeClient with calls via the MarketApi
  • mod supermarket::cache moved to supermarket::cache::campaign - the Cache implementation for Campaigns is now moved to separate, own module

  • struct Caches (mod supermarket::cache) implementation that contains all the cache implementations in 1 struct

TODOs:

  • Way to clean all Caches from struct Caches
  • Mocked clients for AdSlotCache, AdUnitsCache, AdTypeCache
  • Simplify tests by creating Mocked clients for AdSlotClient, AdUnitsClient & AdTypeClient instead of mocking the API calls in /units-for-slot tests (units_for_slot_tests.rs)

pub trait ClientLike<K> {
type Output: Send + 'static;

async fn get_fresh<'a>(&self, key: K) -> Self::Output
Copy link
Member Author

@elpiel elpiel Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just couldn't figure out a way for K to be able to support owned and reference values... I've tried mimicking DashMap and HashMap, but I got beaten by async and the async_trait crate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Caching Market API calls for AdSlots & AdUnits
1 participant