sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.39k stars 182 forks source link

Multiple interval/intervalCap constraints? #176

Open drmrbrewer opened 1 year ago

drmrbrewer commented 1 year ago

I am making calls to an API that has two separate rate limits in place:

Is there a way of adhering to these rate limits using p-queue? So far as I can understand, I can only set a rate limit constraint based on one but not both, using interval/intervalCap?

Richienb commented 1 year ago

Perhaps a custom delay function could be provided that is called to arrange the delays itself?

kent-amplitude commented 1 year ago

What if you had two queues? One configured for 60 requests per minute, and another configured for 4 requests per second, then make each function call run through both queues.

I haven't tested this out, but I think this should work.