ServiceRateLimiter<Id> class
A RateLimiter] implementation that uses a Service
to store rate limiting information.
- Inheritance
-
- Object
- RateLimiter<
Id> - ServiceRateLimiter
Constructors
Properties
- errorMessage → String
-
The error message to send to a
User
who has exceeded the rate limit during the current window.finalinherited -
getId
→ FutureOr<
Id> Function(RequestContext, ResponseContext) -
A callback used to compute the current user ID.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxPointsPerWindow → int
-
The maximum number of points that may be consumed
within the given windowDuration.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
service
→ Service<
Id, Map< String, dynamic> > -
The underlying
Service
used to store data.final - windowDuration → Duration
-
The amount of time, during which, a user is not allowed to consume
more than maxPointsPerWindow.
finalinherited
Methods
-
getCurrentWindow(
RequestContext req, ResponseContext res, DateTime currentTime) → FutureOr< RateLimitingWindow< Id> > -
Computes the current window in which the user is acting.
override
-
getEndpointCost(
RequestContext req, ResponseContext res, RateLimitingWindow< Id> window) → FutureOr<int> -
Computes the amount of points that a given request will cost. This amount
is then added to the amount of points that the user has already consumed
in the current
window
.inherited -
handleRequest(
RequestContext req, ResponseContext res) → Future -
A request middleware that returns
true
if the user has not yet exceeded the maxPointsPerWindow.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rejectRequest(
RequestContext req, ResponseContext res, RateLimitingWindow< Id> window, DateTime currentTime) → FutureOr<Object> -
Signals to a user that they have exceeded the rate limit for the
current window, and terminates execution of the current
RequestContext
.inherited -
sendWindowInformation(
RequestContext req, ResponseContext res, RateLimitingWindow< Id> window) → FutureOr<void> -
Alerts the user of information pertinent to the current
window
.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
updateCurrentWindow(
RequestContext req, ResponseContext res, RateLimitingWindow< Id> window, DateTime currentTime) → FutureOr<void> -
Updates the underlying store with information about the new
window
that the user is operating in.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited