mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-26 14:26:06 +00:00
feat: 限速算法的扩展性
This commit is contained in:
@@ -16,7 +16,19 @@ class RateLimit(stage.PipelineStage):
|
||||
algo: algo.ReteLimitAlgo
|
||||
|
||||
async def initialize(self):
|
||||
self.algo = fixedwin.FixedWindowAlgo(self.ap)
|
||||
|
||||
algo_name = self.ap.pipeline_cfg.data['rate-limit']['algo']
|
||||
|
||||
algo_class = None
|
||||
|
||||
for algo_cls in algo.preregistered_algos:
|
||||
if algo_cls.name == algo_name:
|
||||
algo_class = algo_cls
|
||||
break
|
||||
else:
|
||||
raise ValueError(f'未知的限速算法: {algo_name}')
|
||||
|
||||
self.algo = algo_class(self.ap)
|
||||
await self.algo.initialize()
|
||||
|
||||
async def process(
|
||||
|
||||
Reference in New Issue
Block a user