Skip to content

Change Rate Limiter state dynamically based on external value #320

Open
@jmnunezizu

Description

@jmnunezizu

Hi,

I recently started using this library. Please my apologies if this is somewhere in the docs and I missed it.

My situation:

  • I need to make requests to an external API.
  • The API has a Rate Limit of 60 req/min.
  • The API response includes headers with the rate limit information on max, used, and remaining requests.

Problem:

When the application starts, the "remaining" value is unknown until the first response is received. For this reason, I cannot configure a RateLimiter properly.

Question:

Is there a way to update the state of the rate limiter dynamically? I'd like to, on every request/response loop, check for the rate limiter headers and update the rate limiter accordingly.

Would the above be possible, or is there any other way to achieve the same result?

I was also considering making an initial request to the API to get the value before instantiating the Rate Limiter.

Thanks!

Best,
Jose.-

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions