Module actor

Module actor 

Source
Expand description

Actor-based rate limiter for shared state management

This module implements an actor pattern to ensure thread-safe access to the rate limiter state. All transports communicate with a single actor instance, guaranteeing consistent rate limiting across protocols.

§Architecture

The actor pattern provides:

  • Thread Safety: Single-threaded access to mutable state
  • Async Communication: Non-blocking message passing via channels
  • Protocol Independence: All transports use the same interface

§Example

// Spawn an actor with an adaptive store
let limiter = RateLimiterActor::spawn_adaptive(10000, AdaptiveStore::new());

// Use the handle from any transport
let response = limiter.throttle(request).await?;

Structs§

RateLimiterActor
The rate limiter actor factory
RateLimiterHandle
Handle to communicate with the rate limiter actor

Enums§

RateLimiterMessage
Message types for the rate limiter actor