read_rate_limited.py 549 B

1234567891011121314151617181920212223
  1. from pydantic import Field
  2. from pydantic_settings import BaseSettings, SettingsConfigDict
  3. from typing import List
  4. class ReadRateLimited(BaseSettings):
  5. """限流配置"""
  6. # 统计周期
  7. stat_durations: List[int] = Field(
  8. default_factory=lambda: [
  9. 2, 10, 30, 60, 90, 120, 150, 365
  10. ]
  11. )
  12. # 认为满足限流阅读均值倍数阈值
  13. read_on_avg_threshold: float = 0.2
  14. # 探索次数
  15. base_discover_time: int = 1
  16. # 认为文章限流占比阈值
  17. low_read_rate_threshold: float = 0.5