taolib.testing.data_sync.services.scheduler#

异步调度器。

提供简单的 cron-like 定时调度功能。

Attributes#

Classes#

AsyncScheduler

异步调度器。

Module Contents#

taolib.testing.data_sync.services.scheduler.croniter = None#
taolib.testing.data_sync.services.scheduler.logger#
class taolib.testing.data_sync.services.scheduler.AsyncScheduler(orchestrator: taolib.testing.data_sync.services.orchestrator.SyncOrchestrator, job_repo: taolib.testing.data_sync.repository.job_repo.SyncJobRepository, check_interval: int = 60)#

异步调度器。

根据作业的 schedule_cron 配置定时运行同步作业。

_orchestrator#
_job_repo#
_check_interval = 60#
_running = False#
_task: asyncio.Task[None] | None = None#
async start() None#

启动调度器。

async stop() None#

停止调度器。

async _run_loop() None#

运行循环。

async _check_and_run() None#

检查并运行到期的作业。

_is_due(cron_expr: str, now: datetime.datetime) bool#

检查是否到期。

简化实现:每分钟检查一次,如果 cron 表达式匹配当前分钟则运行。

async _run_job(job_id: str) None#

运行单个作业。