from __future__ import annotations

"""
Copyright (C) 2025 Luciano Guerche

This file is part of rabbitmq-mcp-server.

rabbitmq-mcp-server is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

rabbitmq-mcp-server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with rabbitmq-mcp-server. If not, see <https://www.gnu.org/licenses/>.
"""

"""Reconnection state schema for automatic reconnection management."""

from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class ReconnectionState(BaseModel):
    """Represents the current state of reconnection attempts."""

    model_config = ConfigDict(validate_assignment=True)

    state: str = Field(
        ...,
        description="Current connection state (disconnected, connecting, connected, reconnecting)",
    )
    attempt: int = Field(
        default=0,
        ge=0,
        description="Current reconnection attempt number (0 if not reconnecting)",
    )
    next_attempt_in_seconds: int | None = Field(
        default=None,
        ge=0,
        description="Seconds until next reconnection attempt (None if not reconnecting)",
    )
    total_downtime_seconds: float = Field(
        default=0.0,
        ge=0.0,
        description="Total accumulated downtime in seconds",
    )
    last_reconnect_timestamp: datetime | None = Field(
        default=None,
        description="Timestamp of last successful reconnection (None if never reconnected)",
    )
