"""Configuration model for Apache Kafka transport connections."""

from typing import Any

from pydantic import Field

from .baseconfig import BaseConfig


class KafkaConfig(BaseConfig):
    """
    Configuration model for KafkaLine.
    Inherits 'name' from BaseConfig and defines Kafka-specific parameters.

    Attributes:
        bootstrap_servers (List[str]): A list of Kafka broker addresses (e.g., ["localhost:9092"]).
        topic_name (str): The name of the Kafka topic to produce to and/or consume from.
        group_id (str): The consumer group ID for Kafka consumers.
                        Defaults to "Kurier-default-consumer-group".
        auto_offset_reset (str): The strategy for resetting offsets when there's no committed offset.
                                 Common values are "earliest" or "latest". Defaults to "earliest".
        enable_auto_commit (bool): If true, periodically commit offsets in the background.
                                   Defaults to True.
        auto_commit_interval_ms (int): The frequency in milliseconds that the consumer offsets are
                                       auto-committed to Kafka if `enable_auto_commit` is True.
                                       Defaults to 1000.
        publish_timeout_seconds (int): The maximum time in seconds to wait for a message to be
                                       published to Kafka. Defaults to 10.
        producer_properties (Dict[str, Any]): Additional configuration properties for the Kafka producer.
                                               Defaults to an empty dictionary.
        consumer_properties (Dict[str, Any]): Additional configuration properties for the Kafka consumer.
                                               Defaults to an empty dictionary.
    """

    bootstrap_servers: list[str]
    topic_name: str

    group_id: str = "Kurier-default-consumer-group"
    auto_offset_reset: str = "earliest"
    enable_auto_commit: bool = True
    auto_commit_interval_ms: int = 1000

    publish_timeout_seconds: int = 10

    producer_properties: dict[str, Any] = Field(default_factory=dict)
    consumer_properties: dict[str, Any] = Field(default_factory=dict)
