We may be able to generalize the rate limiting to make it suitable for both use cases, albeit with more setup. Something like:
queue = Queue("default", rate_limit_key="amazon_api_requests")
job = Job(...).with_rate_limit_key("amazon_api_requests")
job = Job(...).with_rate_limit_key("amazon_api_requests").with_rate_limit_partition("customer_id")
Would cause both that job and that queue to share the same global rate limit, with the 3rd job having a rate limit per distinct customer_id.
You'd then initialize/reset/adjust a global rate limit with:
await chancy.push_rate_limit("amazon_api_requests", 30, 60)
We may be able to generalize the rate limiting to make it suitable for both use cases, albeit with more setup. Something like:
Would cause both that job and that queue to share the same global rate limit, with the 3rd job having a rate limit per distinct customer_id.
You'd then initialize/reset/adjust a global rate limit with: