Skip to content

Commit

Permalink
fix conn idle timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
crimson-gao committed Dec 20, 2023
1 parent 45109e3 commit 819fe40
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ import (
"golang.org/x/net/context"
)

var DefaultHttpClientIdleTimeOut = time.Second * 55

// timeout configs
var (
defaultRequestTimeout = 60 * time.Second
defaultRetryTimeout = 90 * time.Second
defaultHttpClient = &http.Client{
Timeout: defaultRequestTimeout,
}
defaultHttpClient = initDefaultHttpClient()
)

func initDefaultHttpClient() *http.Client {
t := http.DefaultTransport.(*http.Transport).Clone()
t.IdleConnTimeout = DefaultHttpClientIdleTimeOut
return &http.Client{
Transport: t,
}
}

func retryReadErrorCheck(ctx context.Context, err error) (bool, error) {
if err == nil {
return false, nil
Expand Down

0 comments on commit 819fe40

Please sign in to comment.