Skip to content

Commit ec151a2

Browse files
committed
[XAPID-1070] reuse the same http client, change maxIdleConnsPerHost
1 parent 8e31e83 commit ec151a2

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

init.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const (
4141
configDownloadQueueSize = "apigeesync_download_queue_size"
4242
configBlobServerBaseURI = "apigeesync_blob_server_base"
4343
configStoragePath = "local_storage_path"
44-
maxIdleConnsPerHost = 10
44+
maxIdleConnsPerHost = 50
4545
httpTimeout = time.Minute
4646
)
4747

@@ -118,20 +118,21 @@ func initPlugin(s apid.Services) (apid.PluginData, error) {
118118
apidClusterId = config.GetString(configApidClusterID)
119119

120120
// initialize tracker client
121+
httpClient := &http.Client{
122+
Transport: &http.Transport{
123+
MaxIdleConnsPerHost: maxIdleConnsPerHost,
124+
},
125+
Timeout: httpTimeout,
126+
CheckRedirect: func(req *http.Request, _ []*http.Request) error {
127+
req.Header.Set("Authorization", getBearerToken())
128+
return nil
129+
},
130+
}
121131

122132
client := &trackerClient{
123133
trackerBaseUrl: configApiServerBaseURI,
124134
clusterId: apidClusterId,
125-
httpclient: &http.Client{
126-
Transport: &http.Transport{
127-
MaxIdleConnsPerHost: maxIdleConnsPerHost,
128-
},
129-
Timeout: httpTimeout,
130-
CheckRedirect: func(req *http.Request, _ []*http.Request) error {
131-
req.Header.Set("Authorization", getBearerToken())
132-
return nil
133-
},
134-
},
135+
httpclient: httpClient,
135136
}
136137

137138
// initialize db manager
@@ -180,9 +181,7 @@ func initPlugin(s apid.Services) (apid.PluginData, error) {
180181
bundleCleanupDelay: bundleCleanupDelay,
181182
downloadQueue: make(chan *DownloadRequest, downloadQueueSize),
182183
isClosed: new(int32),
183-
client: &http.Client{
184-
Timeout: bundleDownloadConnTimeout,
185-
},
184+
client: httpClient,
186185
}
187186

188187
bundleMan.initializeBundleDownloading()

0 commit comments

Comments
 (0)