feat: Implement RateLimiter into enroll_verb_handler and add unit test #1547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What I did
- How I did it
Changes in
at_server_spec
AtRateLimiter
that includes a method calledisRequestAllowed
. This method should return a boolean value based on the rate limit rules.InboundConnection
class to implement theAtRateLimiter
abstract class.Changes in
at_secondary_server
config.yaml
file andat_secondary_config
, introduce two new parameters:maxRequestsPerTimeFrame
andtimeFrameInHours
to define rate limit criteria.isRequestAllowed
method in theInboundConnectionImpl
class (which implementsInboundConnection
) to enforce rate limits on enrollment requests based on the criteria specified in the config.enroll_verb_handler
's_handleEnrollmentRequest
method, call theisRequestAllowed
method on theAtConnection
object. If the method returnstrue
, allow the enrollment request; otherwise, throw anAtThrottleLimitExceeded
exception.GlobalExceptionHandler
to handle theAtThrottleException
. This exception should be used to send a response to the client while preventing the connection from being closed.testingMode
parameter in theconfig.yaml
is set totrue
, allow modifications to the enrollment criteria using the config verb.at_secondary_config
, addmaxRequestsPerTimeFrame
andtimeFrameInMills
parameters to theModifiableConfigs
enum.at_secondary_server_impl
to capture these changes and update the values in theat_secondary_config
.- How to verify it
- Description for the changelog