Skip to content

feat: 添加频率限制功能#105

Open
miaopangpang wants to merge 1 commit intoSnowfall-in-June:mainfrom
miaopangpang:feature/rate-limit-v2
Open

feat: 添加频率限制功能#105
miaopangpang wants to merge 1 commit intoSnowfall-in-June:mainfrom
miaopangpang:feature/rate-limit-v2

Conversation

@miaopangpang
Copy link
Copy Markdown

  • 创建 RateLimiter 类,使用滑动窗口算法实现频率限制
  • 默认限制:同一个域名每分钟30次请求
  • 支持通过 set_rate_limit 方法配置频率限制
  • 支持为特定域名设置不同的限制
  • 在 SunRequests 中集成频率限制调用
  • 在 adata 模块中暴露相关接口

使用方式:
import adata

# 设置默认限制: 30次/分钟
adata.set_rate_limit(30, 60)

# 设置特定域名限制
adata.set_rate_limit(10, 60, domain='api.example.com')

- 创建 RateLimiter 类,使用滑动窗口算法实现频率限制
- 默认限制:同一个域名每分钟30次请求
- 支持通过 set_rate_limit 方法配置频率限制
- 支持为特定域名设置不同的限制
- 在 SunRequests 中集成频率限制调用
- 在 adata 模块中暴露相关接口

使用方式:
    import adata

    # 设置默认限制: 30次/分钟
    adata.set_rate_limit(30, 60)

    # 设置特定域名限制
    adata.set_rate_limit(10, 60, domain='api.example.com')
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.

1 participant