Function increment_rate_limit

Source
pub fn increment_rate_limit(
    key: &str,
    delta: i64,
    window: i64,
) -> Result<Rate, RemoteStateError>
Expand description

Increments a rate limit, returning the number of attempts so far and the expiration time.

The rate limiter is a counter over a period of time. At the end of the period, it will expire, beginning a new period. Window periods should be set to the longest amount of time that a client should be locked out for. The plugin is responsible for performing all rate-limiting logic with the counter value it receives.

In order for this function to succeed, a plugin’s configuration must explicitly declare a permission grant for the prefix of the key being requested. This function will panic if permission has not been granted.

§Arguments

  • key - The key name corresponding to the state counter.
  • delta - The amount to increase the counter by.
  • window - How long each period should be in seconds.