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 check_event_with_metadata(
&self,
signature: EventSignature,
metadata: EventMetadata,
) -> LimitDecision
pub fn check_event_with_metadata( &self, signature: EventSignature, metadata: EventMetadata, ) -> LimitDecision
Process an event with metadata and decide whether to allow or suppress it.
This method captures event metadata on first occurrence for human-readable summaries.
Note: Only available with the human-readable feature flag.
§Arguments
signature- The event signaturemetadata- Event details (level, message, target, fields)
§Returns
A LimitDecision indicating whether to allow or suppress the event.
§Fail-Safe Behavior
Same as check_event: fails open if rate limiting operations fail.
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>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more