Skip to content

Code sync, port limiter fixes#213

Merged
JimMoen merged 13 commits intoemqx:masterfrom
JimMoen:port-limiter-fixs
Sep 23, 2025
Merged

Code sync, port limiter fixes#213
JimMoen merged 13 commits intoemqx:masterfrom
JimMoen:port-limiter-fixs

Conversation

@JimMoen
Copy link
Copy Markdown
Member

@JimMoen JimMoen commented Sep 23, 2025

Port #211 and #212 to master
(except appup)

end;

consume(Name, Tokens) when is_integer(Tokens), Tokens > 0 ->
try ets:update_counter(?TAB, {tokens, Name}, {2, -Tokens, 0, 0}) of
Copy link
Copy Markdown
Member Author

@JimMoen JimMoen Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous consume func would always try consume token even the bucket has already exhausted.
The remaining tokens can be negatived now. which means it borrowed tokens from future.
And the specific pause time will be returned based on the actual number of borrowed tokens and the generation rate.

@JimMoen JimMoen merged commit dcb9b6f into emqx:master Sep 23, 2025
3 checks passed
@JimMoen JimMoen changed the title Code syncc, port limiter fixes Code sync, port limiter fixes Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants