Skip to content

Commit b515905

Browse files
authored
Merge pull request #63 from netlify/timeout-config
Add common configuration structs for HTTP client/server timeouts
2 parents 2c62a0c + 60ca251 commit b515905

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

nconf/timeout.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package nconf
2+
3+
import "time"
4+
5+
// HTTPServerTimeoutConfig represents common HTTP server timeout values
6+
type HTTPServerTimeoutConfig struct {
7+
// Read = http.Server.ReadTimeout
8+
Read time.Duration `mapstructure:"read"`
9+
// Write = http.Server.WriteTimeout
10+
Write time.Duration `mapstructure:"write"`
11+
// Handler = http.TimeoutHandler (or equivalent).
12+
// The maximum amount of time a server handler can take.
13+
Handler time.Duration `mapstructure:"handler"`
14+
}
15+
16+
// HTTPClientTimeoutConfig represents common HTTP client timeout values
17+
type HTTPClientTimeoutConfig struct {
18+
// Dial = net.Dialer.Timeout
19+
Dial time.Duration `mapstructure:"dial"`
20+
// KeepAlive = net.Dialer.KeepAlive
21+
KeepAlive time.Duration `mapstructure:"keep_alive" split_words:"true"`
22+
23+
// TLSHandshake = http.Transport.TLSHandshakeTimeout
24+
TLSHandshake time.Duration `mapstructure:"tls_handshake" split_words:"true"`
25+
// ResponseHeader = http.Transport.ResponseHeaderTimeout
26+
ResponseHeader time.Duration `mapstructure:"response_header" split_words:"true"`
27+
// Total = http.Client.Timeout or equivalent
28+
// The maximum amount of time a client request can take.
29+
Total time.Duration `mapstructure:"total"`
30+
}

0 commit comments

Comments
 (0)