Limit number of concurrent requests to host, with telsa

Hello, I’m using the tesla library to send http requests to a host. However I’m supposed to keep the amount of concurrent requests somewhat low.

To achieve this I used poolboy. The problem with this approach however is that I have to use mock_global during testing, which is not a problem for now, but could become one later on.

Is there a better alternative to this approach? My current telsa adapter is hackney, but it doesn’t matter, if I have to switch.

Take a look at one of the following open source libraries which can be used to rate limit requests.

You could use the external host name as the rate limit identity. Writing your own Tesla middleware to apply the rate limit might be a good approach. Take a look at the existing fuse middleware for inspiration.