feat(MAT-174): Add cron job scheduler and executors
Cron package that syncs jobs from matrixhost portal API, schedules execution with timezone-aware timing, and posts results to Matrix rooms. Includes Brave Search, reminder, and browser scrape (placeholder) executors with formatter. 31 pytest tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
28
cron/executor.py
Normal file
28
cron/executor.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Dispatch cron jobs to the correct executor by job_type."""
|
||||
|
||||
import logging
|
||||
|
||||
from .brave_search import execute_brave_search
|
||||
from .browser_executor import execute_browser_scrape
|
||||
from .reminder import execute_reminder
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
EXECUTORS = {
|
||||
"brave_search": execute_brave_search,
|
||||
"browser_scrape": execute_browser_scrape,
|
||||
"reminder": execute_reminder,
|
||||
}
|
||||
|
||||
|
||||
async def execute_job(job: dict, send_text, matrix_client) -> dict:
|
||||
"""Execute a cron job and return a result dict for reporting."""
|
||||
job_type = job["jobType"]
|
||||
executor = EXECUTORS.get(job_type)
|
||||
|
||||
if not executor:
|
||||
msg = f"Unknown job type: {job_type}"
|
||||
logger.error(msg)
|
||||
return {"status": "error", "error": msg}
|
||||
|
||||
return await executor(job=job, send_text=send_text, matrix_client=matrix_client)
|
||||
Reference in New Issue
Block a user