pub struct BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,{ /* private fields */ }Expand description
Broadcast-based concurrency manager that prevents dogpile effect with semaphore-based concurrency control
When multiple requests arrive for the same cache key:
- First N requests (where N = semaphore capacity) proceed to upstream
- Subsequent requests subscribe to the broadcast channel and wait
- First request to complete broadcasts the result to all waiters
- Waiters reconstruct the response using CacheableResponse::from_cached
Implementations§
Source§impl<Res> BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,
impl<Res> BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,
Sourcepub fn new() -> BroadcastConcurrencyManager<Res>
pub fn new() -> BroadcastConcurrencyManager<Res>
Creates a new broadcast-based concurrency manager.
Trait Implementations§
Source§impl<Res> Clone for BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,
impl<Res> Clone for BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,
Source§fn clone(&self) -> BroadcastConcurrencyManager<Res>
fn clone(&self) -> BroadcastConcurrencyManager<Res>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Res> ConcurrencyManager<Res> for BroadcastConcurrencyManager<Res>where
Res: CacheableResponse + Send + 'static,
<Res as CacheableResponse>::Cached: Send + Sync + Clone + 'static,
impl<Res> ConcurrencyManager<Res> for BroadcastConcurrencyManager<Res>where
Res: CacheableResponse + Send + 'static,
<Res as CacheableResponse>::Cached: Send + Sync + Clone + 'static,
Source§fn check(
&self,
cache_key: &CacheKey,
concurrency: BoundedU8<1, u8::MAX>,
) -> ConcurrencyDecision<Res>
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>,
)
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§impl<Res> Default for BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,
impl<Res> Default for BroadcastConcurrencyManager<Res>where
Res: CacheableResponse,
Source§fn default() -> BroadcastConcurrencyManager<Res>
fn default() -> BroadcastConcurrencyManager<Res>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<Res> Freeze for BroadcastConcurrencyManager<Res>
impl<Res> !RefUnwindSafe for BroadcastConcurrencyManager<Res>
impl<Res> Send for BroadcastConcurrencyManager<Res>
impl<Res> Sync for BroadcastConcurrencyManager<Res>
impl<Res> Unpin for BroadcastConcurrencyManager<Res>
impl<Res> !UnwindSafe for BroadcastConcurrencyManager<Res>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more