DatabaseRateLimiter class
Tracks attempts using the RateLimitedRequestAttempt model.
Admitted attempts are committed independently of the caller's transaction. Rejected attempts are rolled back before the rate limit callback runs.
- Inheritance
-
- Object
- RateLimiter
- DatabaseRateLimiter
Constructors
- DatabaseRateLimiter(RateLimiterConfig config)
- Creates a new DatabaseRateLimiter instance.
Properties
- config → RateLimiterConfig
-
The namespace, limit, and optional rolling window.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
countAttempts(
Session session, {required String key, Transaction? transaction}) → Future< int> -
Counts attempts for
keywithin the configured window, or all time.override -
deleteAttempts(
Session session, {String? key, Duration? olderThan, Transaction? transaction}) → Future< int> -
Deletes attempts within this limiter's domain and source.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
tryRecordAttempt(
Session session, {required String key, Map< String, String> ? extraData}) → Future<bool> -
Atomically admits and records an attempt if budget remains.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited