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.
Rate-limiting Solution - Updated
Problem Statement:
Goals:
Non-Goals:
Implementation Details:
Core Functionality
The solution implements Limiters that provide Leases to requesting Resources. Limiters are configured through a common LimiterConfig file that contains all the configuration properties that can be applied for all limiters. It is the responsibilty of each limiter to ensure the proper configuration is set in this class for the given limiter type.
Leases are produced when a resource attempts to utilize a limiter. The lease may be acquired or denied based on the current state of the limiter. Leases are configured using the LeaseConfig class. For example, the TokenLimiter class uses LeaseConfig to enable requesting a lease with a variable amount of tokens.
Relinquishing a lease releases the limiter according to the limiter implementation.
Linked Limiters
It is possible to compose limiter rules using the LinkedLimiter class.
Example Limiters
Two example limiters have been created: TokenLimiter and FixedWindowLimiter.
TokenLimiter
FixedWindowLimiter
JSON-style resource configuration
ResourceRateLimiter supports (but does not require) JSON-style resource configuration to enable dynamic configuration of rules and resources through JSON hosted in an external source (API Project AppSettings.json file, JSON-based configuration data store, etc.)
A functional sample configuration file has also been provided in SampleResourceRateLimiterConfig.json
Potential Future Enhancements:
Example: Rule A + Rule B + (Rules A + B) + ((Rules A + B) + (Rules B + C)).