Closed girarda closed 10 months ago
Noting that this feature can be useful in other contexts (eg for vector db destination). If possible, we should implement the rate limiter such that it can be reused outside of the a "concurrent CDK" source
Grooming notes:
I can say that https://docs.airbyte.com/integrations/sources/clickup-api/ could use this and benefit people with the following plans https://clickup.com/api/developer-portal/rate-limits/#:~:text=The%20rate%20limit%20varies%20based,requests%20per%20minute%20per%20token.
Free Forever, Unlimited, and Business Plan: 100 requests per minute per token.
Surely, other APIs have those "plan limits" and I do think it's good practice to limit requests to 3rd party APIs to prevent being confused with a bad bot/IP blocking.
What
It should be possible for a source connector to define a credit-based rate limit to avoid busting the API's limit
A simple implementation is to define a limit of N requests for a given time window, and keep a count of the number of request sent during the current window.
Note:
can_submit_request
method needs to be thread-safe because it will be called from multiple workers. It could be protected using a mutexTesting
Acceptance criteria
HttpStream