package com.kt.ai.client.config;

import feign.Logger;
import feign.Request;
import feign.Retryer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * Feign Client 설정
 * - Claude API / GPT-4 API 연동 설정
 * - Timeout, Retry 설정
 *
 * @author AI Service Team
 * @since 1.0.0
 */
@Configuration
public class FeignClientConfig {

    /**
     * Feign Logger Level 설정
     */
    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    /**
     * Feign Request Options (Timeout 설정)
     * - Connect Timeout: 10초
     * - Read Timeout: 5분 (300초)
     */
    @Bean
    public Request.Options requestOptions() {
        return new Request.Options(
                10, TimeUnit.SECONDS,  // connectTimeout
                300, TimeUnit.SECONDS, // readTimeout (5분)
                true                    // followRedirects
        );
    }

    /**
     * Feign Retryer 설정
     * - 최대 3회 재시도
     * - Exponential Backoff: 1초, 5초, 10초
     */
    @Bean
    public Retryer retryer() {
        return new Retryer.Default(
                1000L,    // period (1초)
                5000L,    // maxPeriod (5초)
                3         // maxAttempts (3회)
        );
    }
}
