Create rate limiting window
This commit is contained in:
parent
c7434c220c
commit
c69b8e1405
2 changed files with 17 additions and 1 deletions
|
@ -1 +1,2 @@
|
|||
export 'src/rate_limiter.dart';
|
||||
export 'src/rate_limiter.dart';
|
||||
export 'src/rate_limiting_window.dart';
|
15
lib/src/rate_limiting_window.dart
Normal file
15
lib/src/rate_limiting_window.dart
Normal file
|
@ -0,0 +1,15 @@
|
|||
/// A representation of the abstract "rate-limiting window" in which
|
||||
/// a [user] is accessing some API or endpoint.
|
||||
class RateLimitingWindow<User> {
|
||||
/// The user who is accessing the endpoint.
|
||||
final User user;
|
||||
|
||||
/// The time at which the user's current window began.
|
||||
final DateTime start;
|
||||
|
||||
/// The number of requests the user has already sent within
|
||||
/// the current window.
|
||||
final int requestCount;
|
||||
|
||||
RateLimitingWindow(this.user, this.start, this.requestCount);
|
||||
}
|
Loading…
Reference in a new issue