pub struct RateLimitedAuditSink { /* private fields */ }Expand description
Wraps any AuditSink with any RateLimiter.
On every AuditSink::record_failure call:
- Compute
event.rate_limit_key()(Phase 9 design call (e): compoundclient_id_hint ‖ kid_hint). - Consult the limiter: if admitted, forward to inner sink.
- If denied, increment
dropped_totaland silently drop the event.
The verify hot path NEVER blocks on rate-limit denial — the dropped event simply never reaches the inner sink.
Ops observation pattern (per refinement #1 audit): hold an
Arc<RateLimitedAuditSink> outside the verifier wiring, then
coerce a clone to Arc<dyn AuditSink> for the verifier:
ⓘ
use std::sync::Arc;
use pas_external::{
AuditSink, MemoryRateLimiter, RateLimitedAuditSink, RateLimiter,
};
let limited = Arc::new(RateLimitedAuditSink::new(
real_sink,
Arc::new(MemoryRateLimiter::default()),
));
let dropped_handle = Arc::clone(&limited);
let verifier = verifier.with_audit(limited as Arc<dyn AuditSink>);
// Later, in a health probe:
let _ = dropped_handle.dropped_total();Implementations§
Source§impl RateLimitedAuditSink
impl RateLimitedAuditSink
Sourcepub fn new(
inner: Arc<dyn AuditSink>,
limiter: Arc<dyn RateLimiter>,
) -> RateLimitedAuditSink
pub fn new( inner: Arc<dyn AuditSink>, limiter: Arc<dyn RateLimiter>, ) -> RateLimitedAuditSink
Compose an inner sink with a limiter.
Sourcepub fn dropped_total(&self) -> u64
pub fn dropped_total(&self) -> u64
Total events dropped due to rate-limit denial since construction.
Useful for ops dashboards / health probes that want to detect
“we’re suppressing audit signal because of upstream pressure.”
Relaxed ordering — the counter is monotonic and readers
don’t need cross-thread happens-before guarantees against
audit emissions.
Trait Implementations§
Source§impl AuditSink for RateLimitedAuditSink
impl AuditSink for RateLimitedAuditSink
fn record_failure<'life0, 'async_trait>(
&'life0 self,
event: AuditEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
RateLimitedAuditSink: 'async_trait,
Auto Trait Implementations§
impl !Freeze for RateLimitedAuditSink
impl !RefUnwindSafe for RateLimitedAuditSink
impl Send for RateLimitedAuditSink
impl Sync for RateLimitedAuditSink
impl Unpin for RateLimitedAuditSink
impl UnsafeUnpin for RateLimitedAuditSink
impl !UnwindSafe for RateLimitedAuditSink
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