Currently We are triggering rate-limiting functionality, each time when user hits the service, code will check for the count in redis, if submission count is within the configured limit, we increment the count and allow the user to perform the operation otherwise we need to recursively check for the limit for every 1 sec until validation succeeds.
async function _rateLimit(key) {
let islimitExceeded = await redisClient.checkSubmissionCount(key,
constants.REQUEST_LIMIT); // REQUEST_LIMIT is the configured limit lets take as 10
if (!islimitExceeded) {
await redisClient.incrementSubmissionCount(key);// increment the count and allow the user to perform the operation
}
else {
//Need a code which will continuously trigger the ratelimit(key) method
}
}
Kindly help on this. Thanks