Skip to content

Commit

Permalink
Correct units for overpenalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Jan 2, 2024
1 parent 09800a7 commit 02bef2e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/opuntia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ calculate(#token_bucket_shaper{shape = {MaximumTokens, Rate, TimeUnit},
debt = OverUsedRateNowInUnits},
{NewShaper, RoundedDelayMs};
%% I penalised you too much last time, you get off now but with a future bill
Punish when Punish =< +0.0 ->
Punish when Punish < +0.0 ->
DebtInUnits = convert_time_unit(-Punish, millisecond, TimeUnit),
NewShaper = Shaper#token_bucket_shaper{available_tokens = TokensAvailable,
last_update = NativeNow,
debt = -Punish},
debt = DebtInUnits},
{NewShaper, 0}
end.

Expand Down

0 comments on commit 02bef2e

Please sign in to comment.