Skip to content

Commit

Permalink
feat: Implement AtRateLimiter spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sitaram-kalluri committed Sep 11, 2023
1 parent dd1c95d commit 2b190f0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/at_server_spec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.15
- feat: Introduce AtRateLimiter to limit the requests based on the criteria defined
- fix: Modify InboundConnection to implement AtRateLimiter to limit requests
## 3.0.14
- fix: Rename TOTP to OTP
## 3.0.13
Expand Down
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();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'dart:io';
import 'package:at_server_spec/src/at_rate_limiter/at_rate_limiter.dart';
import 'package:at_server_spec/src/connection/at_connection.dart';

abstract class InboundConnection extends AtConnection {
abstract class InboundConnection extends AtConnection implements AtRateLimiter {
///Returns true if remote socket and remote port of this and connection matches
bool equals(InboundConnection connection);

Expand Down
4 changes: 2 additions & 2 deletions packages/at_server_spec/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_server_spec
description: A Dart library containing abstract classes that defines what implementations of the root and secondary servers are responsible for.
version: 3.0.14
version: 3.0.15
repository: https://github.com/atsign-foundation/at_server
homepage: https://docs.atsign.com
documentation: https://docs.atsign.com/atplatform/secondaryserver
Expand All @@ -10,7 +10,7 @@ environment:

dependencies:
meta: ^1.8.0
at_commons: ^3.0.54
at_commons: ^3.0.55

dev_dependencies:
lints: ^1.0.1

0 comments on commit 2b190f0

Please sign in to comment.