# Info: Redis KCL schemas for provisioning (Provisioning)
# Author: Example Template
# Release: 0.0.1
# Date: $(date +%Y-%m-%d)

schema Redis:
    """
    Redis configuration schema for infrastructure provisioning
    """
    name: str = "redis"
    version: str

    # Network configuration
    port: int = 6379
    bind_address: str = "127.0.0.1"

    # Memory configuration
    maxmemory: str = "256mb"
    maxmemory_policy: "noeviction" | "allkeys-lru" | "volatile-lru" | "allkeys-random" | "volatile-random" | "volatile-ttl" = "allkeys-lru"

    # Persistence configuration
    persistence: bool = True
    save_interval: str = "900 1 300 10 60 10000"  # Save every 900s if 1 key changed, etc.

    # Security
    requirepass?: str

    # Replication
    master_host?: str
    master_port?: int

    # Clustering
    cluster_enabled: bool = False
    cluster_config_file?: str

    # Logging
    loglevel: "debug" | "verbose" | "notice" | "warning" = "notice"
    logfile: str = "/var/log/redis/redis-server.log"

    # Performance
    tcp_keepalive: int = 300
    timeout: int = 0

    # Validation
    check:
        port > 0 and port < 65536, "Port must be between 1 and 65535"
        len(version) > 0, "Version must be specified"
        master_port == Undefined or (master_port > 0 and master_port < 65536), "Master port must be valid if specified"