RateLimitAllowedEvent class final
Event published when a request is allowed under the configured rate limit.
Observers can use this event to:
- Track successful, allowed requests.
- Update monitoring metrics (e.g., allowed request counters).
- Trigger auditing or logging of usage patterns.
- Implement dynamic behavior based on allowed requests (e.g., adaptive throttling).
This event is a subclass of RateLimitEvent and carries:
source: The identifier of the entity making the request (e.g., user ID, IP address, API key).- limitName: The name of the rate-limited resource or bucket (e.g.,
"login_attempts"). timestamp: Optional time at which the event occurred; defaults to the current time.
Example
// Create an event for an allowed request
final allowedEvent = RateLimitAllowedEvent('user:42', 'login_attempts');
// Publish the event to the application event system
eventPublisher.publish(allowedEvent);
// Observer can handle this event to increment metrics
allowedEventListener.onEvent(allowedEvent);
Related Components
- RateLimitDeniedEvent: Counterpart event published when a request is blocked.
- RateLimitMetrics: Can be updated in response to allowed events.
- RateLimitStorage: Maintains counters that result in allowed events.
- RateLimitManager: Aggregates multiple storages and triggers allowed/blocked events.
- Inheritance
-
- Object
- RateLimitEvent
- RateLimitAllowedEvent
Constructors
- RateLimitAllowedEvent(Object source, String limitName, [DateTime? timestamp])
-
Creates a new event indicating that a request was allowed by the rate limiter.
const
Properties
Methods
-
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode, andtoString.inherited -
getPackageName(
) → String -
Represents an abstraction for identifying the package that an object,
resource, or service belongs to.
inherited
-
getSource(
) → Object -
Returns the source of the event.
inherited
-
getTimestamp(
) → DateTime -
Returns the timestamp of the event.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
toStringOptions(
) → ToStringOptions -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited