Testing Our Rate Limiter
Follow the step-by-step instructions to test the rate limiter.
We'll cover the following
Rate limiters will limit the number of concurrent requests we can process at a given time. Let’s write a test case for the same to check whether our rate limiter works as expected.
Making our API call
First, we will create a function that can make an API call to our server. We would want to know whether the API call succeeded and whether we received a 200 response. If we received a 429 response instead, it would imply that our rate limiter had kicked in! Our function will also accept a count to keep track of which iteration of our API call succeeded or failed and WaitGroup to be able to notify the caller that this API call is done.
Get hands-on with 1400+ tech skills courses.