-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement AtRateLimiter spec changes
- Loading branch information
1 parent
dd1c95d
commit 2b190f0
Showing
4 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/at_server_spec/lib/src/at_rate_limiter/at_rate_limiter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// A rate limiter class that allows controlling the rate of requests within a specified time frame. | ||
/// | ||
/// This class provides a way to limit the number of requests that can be made | ||
/// within a specified time frame. It keeps track of the timestamps of previous | ||
/// requests and allows requests to be made only if they do not exceed the | ||
/// maximum allowed requests per time frame. | ||
abstract class AtRateLimiter { | ||
/// The maximum number of requests allowed within the specified time frame. | ||
late int maxRequestsPerTimeFrame; | ||
|
||
/// The duration of the time frame within which requests are limited. | ||
late int timeFrameInMillis; | ||
|
||
/// Checks whether a new request is allowed based on the rate limiting rules. | ||
/// | ||
/// Returns `true` if the request is allowed, or `false` if it exceeds the rate limit. | ||
bool isRequestAllowed(); | ||
} |
3 changes: 2 additions & 1 deletion
3
packages/at_server_spec/lib/src/connection/inbound_connection.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters