Skip to content

Commit

Permalink
Merge pull request #124 from containerish/update-skynet-client
Browse files Browse the repository at this point in the history
Add: updated http client for skynet
  • Loading branch information
guacamole committed Mar 27, 2022
2 parents b67ac6c + d45dfe2 commit 38e058d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions skynet/skynet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ func NewClient(oc *config.OpenRegistryConfig) *Client {
}

skynetClient := skynet.NewCustom(oc.SkynetConfig.SkynetPortalURL, opts)
httpClient := http.DefaultClient
httpClient.Timeout = time.Second * 60
httpClient := NewHttpClientForSkynet()

return &Client{
skynet: &skynetClient,
Expand Down Expand Up @@ -107,3 +106,16 @@ func (c *Client) Metadata(skylink string) (*skynet.Metadata, error) {

return metadata, nil
}

func NewHttpClientForSkynet() *http.Client {
t := http.DefaultTransport.(*http.Transport).Clone()
t.MaxIdleConns = 100
t.MaxConnsPerHost = 100
t.MaxIdleConnsPerHost = 100

return &http.Client{
Transport: t,
CheckRedirect: http.DefaultClient.CheckRedirect,
Timeout: time.Minute * 20, //sounds super risky maybe find an alternative
}
}

0 comments on commit 38e058d

Please sign in to comment.