read_rate_limited.py 528 B

123456789101112131415161718192021
  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: [2, 10, 30, 60, 90, 120, 150, 365]
  9. )
  10. # 认为满足限流阅读均值倍数阈值
  11. read_on_avg_threshold: float = 0.2
  12. # 探索次数
  13. base_discover_time: int = 1
  14. # 认为文章限流占比阈值
  15. low_read_rate_threshold: float = 0.5