Respecting API rate limits
I’ve just solve a long-standing issue with my system - respecting API rate limits of external integrations.
A few months into running AutoReceipts I realised I was hitting Xero’s api rate limits.
Looking into a solution, I realised it was a deep problem to solve properly. Xero has 4 rules you have to respect.
To get into Xero’s app store you need to have made an attempt at respecting their limits.
I was busy so decided on a quick and dirty solution for now - sleep for a second after each request. This worked fine because I only had one worker that was fetching from Xero. But it slowed the app down a lot.
But now I have two apps, each with its own worker fetching from Xero, that solution won’t cut it any more. What to do?
I could create a shared queue for jobs that make Xero requests, but