@@ -15,22 +15,25 @@ var (
1515 ollamaClient * http.Client
1616)
1717
18+ // createTransport creates a shared HTTP transport with optimized settings
19+ func createTransport () * http.Transport {
20+ return & http.Transport {
21+ TLSHandshakeTimeout : 10 * time .Second ,
22+ MaxIdleConns : 10 ,
23+ IdleConnTimeout : 30 * time .Second ,
24+ DisableCompression : true ,
25+ TLSClientConfig : & tls.Config {
26+ InsecureSkipVerify : false ,
27+ },
28+ }
29+ }
30+
1831// GetClient returns a shared HTTP client with optimized settings for cloud APIs
1932func GetClient () * http.Client {
2033 clientOnce .Do (func () {
21- transport := & http.Transport {
22- TLSHandshakeTimeout : 10 * time .Second ,
23- MaxIdleConns : 10 ,
24- IdleConnTimeout : 30 * time .Second ,
25- DisableCompression : true ,
26- TLSClientConfig : & tls.Config {
27- InsecureSkipVerify : false ,
28- },
29- }
30-
3134 sharedClient = & http.Client {
3235 Timeout : 30 * time .Second ,
33- Transport : transport ,
36+ Transport : createTransport () ,
3437 }
3538 })
3639 return sharedClient
@@ -39,19 +42,9 @@ func GetClient() *http.Client {
3942// GetOllamaClient returns an HTTP client with extended timeout for local Ollama inference
4043func GetOllamaClient () * http.Client {
4144 ollamaClientOnce .Do (func () {
42- transport := & http.Transport {
43- TLSHandshakeTimeout : 10 * time .Second ,
44- MaxIdleConns : 10 ,
45- IdleConnTimeout : 30 * time .Second ,
46- DisableCompression : true ,
47- TLSClientConfig : & tls.Config {
48- InsecureSkipVerify : false ,
49- },
50- }
51-
5245 ollamaClient = & http.Client {
5346 Timeout : 10 * time .Minute , // 10 minutes for local inference
54- Transport : transport ,
47+ Transport : createTransport () ,
5548 }
5649 })
5750 return ollamaClient
0 commit comments