timeout

package
v0.0.0-...-5044e41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 13 Imported by: 19

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

View Source
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

View Source
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.

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 NewClient

func NewClient(connectTimeout time.Duration, readWriteTimeout time.Duration) *http.Client

NewClient returns a new http client with custom connect and r/w timeouts.

func NewDefaultClient

func NewDefaultClient() *http.Client

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL