"""Job execution engine."""
import asyncio
from typing import Callable

class ExecutionEngine:
    """Executes jobs with configurable handlers."""
    def __init__(self, queue):
        self.queue = queue
        self.handlers = {}
        # Currently: no timeout, no retry logic
    
    def register_handler(self, name: str, handler: Callable) -> None:
        """Register a job handler function."""
        self.handlers[name] = handler
    
    async def run_job(self, job) -> dict:
        """Execute a single job (no timeout/retry currently)."""
        handler = self.handlers.get(job.handler)
        if not handler:
            return {"status": "failed", "reason": "handler_not_found"}
        try:
            result = await handler(job.payload)
            return {"status": "success", "result": result}
        except Exception as e:
            return {"status": "failed", "reason": str(e)}
