Skip to main content

ConcurrencyManager

Trait ConcurrencyManager 

Source
pub trait ConcurrencyManager<Res>: Send + Sync
where Res: CacheableResponse,
{ // Required methods fn check( &self, cache_key: &CacheKey, concurrency: BoundedU8<1, u8::MAX>, ) -> ConcurrencyDecision<Res>; fn resolve( &self, cache_key: &CacheKey, cache_value: &CacheValue<<Res as CacheableResponse>::Cached>, ); fn cleanup(&self, cache_key: &CacheKey); }
Expand description

Trait for managing concurrent requests to prevent dogpile effect

Required Methods§

Source

fn check( &self, cache_key: &CacheKey, concurrency: BoundedU8<1, u8::MAX>, ) -> ConcurrencyDecision<Res>

Check if this request should proceed to upstream or await an existing request

Source

fn resolve( &self, cache_key: &CacheKey, cache_value: &CacheValue<<Res as CacheableResponse>::Cached>, )

Notify waiting requests that the response is ready and return it back

Source

fn cleanup(&self, cache_key: &CacheKey)

Cleanup stale entry from in-flight map (e.g., after channel closed error)

Implementations on Foreign Types§

Source§

impl<Res, T> ConcurrencyManager<Res> for Arc<T>

Source§

fn check( &self, cache_key: &CacheKey, concurrency: BoundedU8<1, u8::MAX>, ) -> ConcurrencyDecision<Res>

Source§

fn resolve( &self, cache_key: &CacheKey, cache_value: &CacheValue<<Res as CacheableResponse>::Cached>, )

Source§

fn cleanup(&self, cache_key: &CacheKey)

Implementors§

Source§

impl<Res> ConcurrencyManager<Res> for BroadcastConcurrencyManager<Res>
where Res: CacheableResponse + Send + 'static, <Res as CacheableResponse>::Cached: Send + Sync + Clone + 'static,

Source§

impl<Res> ConcurrencyManager<Res> for NoopConcurrencyManager
where Res: CacheableResponse + Send + 'static,