pub struct RateLimiter<S>{ /* private fields */ }Expand description
Coordinates rate limiting decisions.
Implementations§
Source§impl<S> RateLimiter<S>
impl<S> RateLimiter<S>
Sourcepub fn new(
registry: SuppressionRegistry<S>,
metrics: Metrics,
circuit_breaker: Arc<CircuitBreaker>,
) -> Self
pub fn new( registry: SuppressionRegistry<S>, metrics: Metrics, circuit_breaker: Arc<CircuitBreaker>, ) -> Self
Create a new rate limiter.
§Arguments
registry- The suppression registry (which contains the clock)metrics- Metrics trackercircuit_breaker- Circuit breaker for fail-safe operation
Sourcepub fn check_event(&self, signature: EventSignature) -> LimitDecision
pub fn check_event(&self, signature: EventSignature) -> LimitDecision
Process an event and decide whether to allow or suppress it.
§Arguments
signature- The event signature
§Returns
A LimitDecision indicating whether to allow or suppress the event.
§Fail-Safe Behavior
If rate limiting operations fail (circuit breaker open), this method fails open and allows all events through to preserve observability.
§Performance
This method is designed for the hot path:
- Fast hash lookup in sharded map
- Lock-free atomic operations where possible
- No allocations in common case
Sourcepub fn registry(&self) -> &SuppressionRegistry<S>
pub fn registry(&self) -> &SuppressionRegistry<S>
Get a reference to the registry.
Sourcepub fn circuit_breaker(&self) -> &Arc<CircuitBreaker>
pub fn circuit_breaker(&self) -> &Arc<CircuitBreaker>
Get a reference to the circuit breaker.
Trait Implementations§
Source§impl<S> Clone for RateLimiter<S>
impl<S> Clone for RateLimiter<S>
Source§fn clone(&self) -> RateLimiter<S>
fn clone(&self) -> RateLimiter<S>
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 moreAuto Trait Implementations§
impl<S> Freeze for RateLimiter<S>where
S: Freeze,
impl<S> !RefUnwindSafe for RateLimiter<S>
impl<S> Send for RateLimiter<S>
impl<S> Sync for RateLimiter<S>
impl<S> Unpin for RateLimiter<S>where
S: Unpin,
impl<S> !UnwindSafe for RateLimiter<S>
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