Skip to content

feat: implement rate limiting for server and tools #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

muzig
Copy link

@muzig muzig commented Apr 22, 2025

Description

新增了基于令牌桶算法的速率限制组件,用于控制工具调用的频率,防止资源过度使用和滥用。该组件允许为不同工具设置不同的调用频率限制,并提供了一个统一的接口进行速率控制。

Related Issue

Fixes #(issue)

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement

How Has This Been Tested?

  • 已测试不同工具在默认和自定义限制下的调用频率
  • 验证了突发请求处理和令牌恢复机制的正确性
  • 模拟高并发环境下的性能和准确性

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@jesse-engineer
Copy link
Collaborator

jesse-engineer commented Apr 24, 2025

这个feature很好,不过在实现上可能有一些其他更优的设计方式,比如为call tool设计一个middleware,我们可以讨论一下

@muzig
Copy link
Author

muzig commented Apr 29, 2025

thx for review. 抽出 component 包想的是朝这个方向发展,只是目前没有太多参考的用例,所以简单化暂时没有引入 middleware 。引入 middleware 效果,这样后期扩展其他功能相对稳定一些。

@jesse-engineer
Copy link
Collaborator

我觉得可以在早期设计时就引入middleware,这样可以避免后期break change。

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