package com.lincfusion.udyamlinc.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.client.RestClient; /** * The HTTP client used for external feeds, and the scheduler that drives them. * *
Short, explicit timeouts are the point: a government endpoint that hangs * must fail the nightly job quickly, not hold a thread until someone notices. * Nothing in the request path uses this client — see ARCHITECTURE §2.1. */ @Configuration @EnableScheduling public class ExternalFeedConfig { @Value("${udyam.ingestion.http.connect-timeout-ms:10000}") private int connectTimeoutMs; @Value("${udyam.ingestion.http.read-timeout-ms:30000}") private int readTimeoutMs; @Bean("externalFeedClient") public RestClient externalFeedClient(RestClient.Builder builder) { SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); factory.setConnectTimeout(connectTimeoutMs); factory.setReadTimeout(readTimeoutMs); return builder.requestFactory(factory).build(); } }