"""
Task Manager Models

包含任务优先队列、任务配置等数据模型。
"""

import logging
from datetime import datetime
from enum import Enum

logger = logging.getLogger(__name__)


class TaskPriority(int, Enum):
    """任务优先级"""
    LOW = 0
    NORMAL = 1
    HIGH = 2
    URGENT = 3


class TaskConfig:
    """任务配置"""

    def __init__(
        self,
        max_retries: int = 3,
        retry_delay: int = 5,  # seconds
        timeout: int = 300,  # seconds
        exponential_backoff: bool = True,
        max_concurrent: int = 5  # 最大并发数
    ):
        self.max_retries = max_retries
        self.retry_delay = retry_delay
        self.timeout = timeout
        self.exponential_backoff = exponential_backoff
        self.max_concurrent = max_concurrent


class TaskItem:
    """任务队列项"""

    def __init__(self, task_id: str, priority: TaskPriority = TaskPriority.NORMAL):
        self.task_id = task_id
        self.priority = priority
        self.created_at = datetime.now().timestamp()

    def __lt__(self, other):
        """优先级比较（用于优先队列）"""
        if self.priority != other.priority:
            return self.priority > other.priority  # 高优先级在前
        return self.created_at < other.created_at  # 相同优先级，先创建的在前
