package com.tuoheng.config.http;

import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
@Getter
@Setter
public class RestProperties {

    public final static String HTTP = "http";

    public final static String HTTPS = "https";

    /**
     * 连接超时, 默认10秒
     */
    @Value("${spring.http.restTemplate.connect.timeout: 10000}")
    private Integer connectTimeout;

    /**
     * 响应超时, 默认2分钟
     */
    @Value("${spring.http.restTemplate.read.timeout: 120000}")
    private Integer readTimeout;

    /**
     * 请求超时时间, 默认10秒
     */
    @Value("${spring.http.restTemplate.connection.request.timeout: 10000}")
    private Integer connectionRequestTimeout;

    /**
     * 请求失败重试次数， 默认重试3次
     */
    @Value("${spring.http.restTemplate.retryCount: 3}")
    private Integer retryCount;

    /**
     * 请求失败重试开关，默认开启
     */
    @Value("${spring.http.restTemplate.requestSentRetryEnabled: true}")
    private Boolean requestSentRetryEnabled;

    /**
     * 线程池最大连接数，默认1000
     */
    @Value("${spring.http.restTemplate.pool.maxTotal: 1000}")
    private Integer maxTotal;

    /**
     * 线程池主机最大并发数，默认100
     */
    @Value("${spring.http.restTemplate.pool.maxPerRoute: 100}")
    private Integer maxPerRoute;

    /**
     * 线程池空闲连接过期时间，默认60秒
     */
    @Value("${spring.http.restTemplate.pool.validateAfterInactivity: 60000}")
    private Integer validateAfterInactivity;
}
