Kit / Kit/excess_flow

Expose a way to determine if the rate limit is already hit?

Open
#5 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
21
Forks
2
PR merge metrics
No merged PRs in 30d

Description

If this exists already perhaps you can help me identify how to do it. I'm looking for a way to detect whether a particular key will overflow in the next call. Digging into the source it looks like it would be using this method
within_rate_limit? but would need to not increment the counter

```
def next_within_rate_limit?
ExcessFlow::GlobalMutex.locked(lock_key: configuration.lock_key) do
cleanup_stale_counters

if current_requests < configuration.limit
true
else
false
end
end
end
end
```

The big difference is it wouldn't call the "bump_counter" method.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing within_rate_limit? entry point and tracing cleanup_stale_counters, current_requests, and bump_counter. Confirm how the rate-limit state is checked, then add a non-incrementing way to determine whether the next call would exceed the configured limit and verify that the counter remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
redis, ruby
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.