39 lines
839 B
Python
39 lines
839 B
Python
"""
|
|
AsyncHandler 抽象基类
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any
|
|
|
|
from app.scheduler.models import StateChange
|
|
from app.scheduler.registry import JobRegistry
|
|
from app.scheduler.slot_manager import SlotManager
|
|
|
|
|
|
class AsyncHandler(ABC):
|
|
"""第三方异步任务处理器基类"""
|
|
|
|
name: str
|
|
slot_key: str
|
|
max_slots: int
|
|
|
|
@abstractmethod
|
|
async def tick(
|
|
self,
|
|
jobs: list[Any],
|
|
registry: JobRegistry,
|
|
slots: SlotManager,
|
|
) -> list[StateChange]:
|
|
"""
|
|
每个 Tick 执行一次。
|
|
|
|
Args:
|
|
jobs: 当前 running 状态的作业记录列表
|
|
registry: 作业注册表(用于读写 Redis 状态)
|
|
slots: 全局槽位管理器
|
|
|
|
Returns:
|
|
状态变更列表
|
|
"""
|
|
pass
|