Documentation
¶
Overview ¶
Package timeout provides an http.Client that closes a connection if it takes too long to establish, or stays idle for too long.
Index ¶
Constants ¶
const ( // DefaultConnectTimeout is the default duration we're willing to wait to establish a connection DefaultConnectTimeout time.Duration = 30 * time.Second // DefaultIdleTimeout is the duration after which, if there's no I/O activity, we declare a connection dead DefaultIdleTimeout = 60 * time.Second )
Variables ¶
var IgnoreCertificateErrors = os.Getenv("HTTPKIT_IGNORE_CERTIFICATE_ERRORS") == "1"
IgnoreCertificateErrors is a dangerous option that instructs all timeout clients to ignore HTTPS certificate errors. This is used mostly in development, to use debugging proxies together with any timeout-powered application.
var ThrottlerPool *iothrottler.IOThrottlerPool
ThrottlerPool is the singleton pool from `iothrottler` that package timeout uses to manage all connections.
Functions ¶
func GetBPS ¶
func GetBPS() float64
GetBPS returns the last measured number of bytes transferred in a 1-second interval as a floating point value.
func NewDefaultClient ¶
NewDefaultClient returns a new http client with default connect and r/w timeouts.
func SetSimulateOffline ¶
func SetSimulateOffline(enabled bool)
SetSimulateOffline enables or disables offline simulation. When enabled, all connection attempts will return a *net.OpError with "simulated offline" contained in its string representation.
Types ¶
This section is empty.