package com.yushu.framework.config;

import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Tomcat配置
 * 
 * @author YuShu
 */
@Configuration
public class TomcatConfig {

    /**
     * 自定义Tomcat配置，增加异步请求超时时间
     */
    @Bean
    public WebServerFactoryCustomizer<TomcatServletWebServerFactory> webServerFactoryCustomizer() {
        return factory -> factory.addConnectorCustomizers((Connector connector) -> {
            // 设置异步请求超时时间为10分钟（600,000毫秒）
            // 此配置对需要长时间处理的异步请求有效
            connector.setAsyncTimeout(600000);
        });
    }
}
