pub fn calculate_proportional_time_adjustment(
last_refresh: Instant,
now: Instant,
elapsed: Duration,
window_duration: Duration,
tokens_added: usize,
max_tokens: usize,
) -> InstantExpand description
Calculate the proportional time adjustment for partial token refill
When tokens are partially refilled, the last refresh time needs to be adjusted proportionally to maintain accurate rate limiting.
§Arguments
last_refresh- The last refresh timenow- Current timeelapsed- Time elapsed since last refreshwindow_duration- Duration of the rate limiting windowtokens_added- Number of tokens that were addedmax_tokens- Maximum number of tokens in the bucket
§Returns
The adjusted last refresh time