-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add same speed improvements to split car fetching as for remote car (…
…single file).
- Loading branch information
1 parent
cf3aa2c
commit 4396069
Showing
9 changed files
with
193 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1 @@ | ||
package main | ||
|
||
import ( | ||
"net" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/klauspost/compress/gzhttp" | ||
) | ||
|
||
var ( | ||
defaultMaxIdleConnsPerHost = 100 | ||
defaultTimeout = 1000 * time.Second | ||
defaultKeepAlive = 180 * time.Second | ||
) | ||
|
||
func newHTTPTransport() *http.Transport { | ||
return &http.Transport{ | ||
IdleConnTimeout: time.Minute, | ||
MaxConnsPerHost: defaultMaxIdleConnsPerHost, | ||
MaxIdleConnsPerHost: defaultMaxIdleConnsPerHost, | ||
MaxIdleConns: defaultMaxIdleConnsPerHost, | ||
Proxy: http.ProxyFromEnvironment, | ||
DialContext: (&net.Dialer{ | ||
Timeout: defaultTimeout, | ||
KeepAlive: defaultKeepAlive, | ||
}).DialContext, | ||
ForceAttemptHTTP2: true, | ||
// MaxIdleConns: 100, | ||
TLSHandshakeTimeout: 10 * time.Second, | ||
// ExpectContinueTimeout: 1 * time.Second, | ||
} | ||
} | ||
|
||
// newHTTPClient returns a new Client from the provided config. | ||
// Client is safe for concurrent use by multiple goroutines. | ||
func newHTTPClient() *http.Client { | ||
tr := newHTTPTransport() | ||
|
||
return &http.Client{ | ||
Timeout: defaultTimeout, | ||
Transport: gzhttp.Transport(tr), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package rangecache | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package rangecache | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package splitcarfetcher | ||
|
||
import ( | ||
"net" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/klauspost/compress/gzhttp" | ||
) | ||
|
||
var ( | ||
DefaultMaxIdleConnsPerHost = 100 | ||
DefaultTimeout = 1000 * time.Second | ||
DefaultKeepAlive = 180 * time.Second | ||
) | ||
|
||
func NewHTTPTransport() *http.Transport { | ||
return &http.Transport{ | ||
IdleConnTimeout: time.Minute, | ||
MaxConnsPerHost: DefaultMaxIdleConnsPerHost, | ||
MaxIdleConnsPerHost: DefaultMaxIdleConnsPerHost, | ||
MaxIdleConns: DefaultMaxIdleConnsPerHost, | ||
Proxy: http.ProxyFromEnvironment, | ||
DialContext: (&net.Dialer{ | ||
Timeout: DefaultTimeout, | ||
KeepAlive: DefaultKeepAlive, | ||
}).DialContext, | ||
ForceAttemptHTTP2: true, | ||
// MaxIdleConns: 100, | ||
TLSHandshakeTimeout: 10 * time.Second, | ||
// ExpectContinueTimeout: 1 * time.Second, | ||
} | ||
} | ||
|
||
// NewHTTPClient returns a new Client from the provided config. | ||
// Client is safe for concurrent use by multiple goroutines. | ||
func NewHTTPClient() *http.Client { | ||
tr := NewHTTPTransport() | ||
|
||
return &http.Client{ | ||
Timeout: DefaultTimeout, | ||
Transport: gzhttp.Transport(tr), | ||
} | ||
} |
Oops, something went wrong.