Documentation ¶
Index ¶
Constants ¶
View Source
const ( // NetworkConnect is a pseudo network name to instruct the dialer to establish // a CONNECT tunnel to the proxy. NetworkConnect = "connect" // NetworkPersistent is a pseudo network name to instruct the dialer to // signal the proxy to establish a persistent HTTP connection over which // one or more HTTP requests can be sent directly. NetworkPersistent = "persistent" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BanditDialer ¶
type BanditDialer struct {
// contains filtered or unexported fields
}
BanditDialer is responsible for continually choosing the optimized dialer.
func New ¶
func New(opts Options) (*BanditDialer, error)
New creates a new bandit given the available dialers and options with callbacks to be called when a dialer is selected, an error occurs, etc.
func (*BanditDialer) Close ¶
func (o *BanditDialer) Close()
func (*BanditDialer) DialContext ¶
type Dialer ¶
type Dialer interface { // DialProxy dials the proxy but does not yet dial the origin. DialProxy(ctx context.Context) (net.Conn, error) // SupportsAddr indicates whether this Dialer supports the given addr. If it does not, the // balancer will not attempt to dial that addr with this Dialer. SupportsAddr(network, addr string) bool // DialContext dials out to the given origin. failedUpstream indicates whether // this was an upstream error (as opposed to errors connecting to the proxy). DialContext(ctx context.Context, network, addr string) (conn net.Conn, failedUpstream bool, err error) // Name returns the name for this Dialer Name() string // Label returns a label for this Dialer (includes Name plus more). Label() string // JustifiedLabel is like Label() but with elements justified for line-by // -line display. JustifiedLabel() string // Location returns the country code, country name and city name of the // dialer, in this order. Location() (string, string, string) // Protocol returns a string representation of the protocol used by this // Dialer. Protocol() string // Addr returns the address for this Dialer Addr() string // Trusted indicates whether or not this dialer is trusted Trusted() bool // NumPreconnecting returns the number of pending preconnect requests. NumPreconnecting() int // NumPreconnected returns the number of preconnected connections. NumPreconnected() int // MarkFailure marks a dial failure on this dialer. MarkFailure() // EstRTT provides a round trip delay time estimate, similar to how RTT is // estimated in TCP (https://tools.ietf.org/html/rfc6298) EstRTT() time.Duration // EstBandwidth provides the estimated bandwidth in Mbps EstBandwidth() float64 // EstSuccessRate returns the estimated success rate dialing this dialer. EstSuccessRate() float64 // Attempts returns the total number of dial attempts Attempts() int64 // Successes returns the total number of dial successes Successes() int64 // ConsecSuccesses returns the number of consecutive dial successes ConsecSuccesses() int64 // Failures returns the total number of dial failures Failures() int64 // ConsecFailures returns the number of consecutive dial failures ConsecFailures() int64 // Succeeding indicates whether or not this dialer is currently good to use Succeeding() bool // DataSent returns total bytes of application data sent to connections // created via this dialer. DataSent() uint64 // DataRecv returns total bytes of application data received from // connections created via this dialer. DataRecv() uint64 // Stop stops background processing for this Dialer. Stop() WriteStats(w io.Writer) }
Dialer provides the ability to dial a proxy and obtain information needed to effectively load balance between dialers.
type Options ¶ added in v7.6.82
type Options struct { // The available dialers to use when creating a new bandit Dialers []Dialer // OnError is the onError callback that is called when bandit encounters a dial error OnError func(error, bool) // OnSuccess is the callback that is called by bandit after a successful dial. OnSuccess func(Dialer) // StatsTracker is a stats.Tracker bandit should be configured to use (a callback that is called // when a dialer is selected) StatsTracker stats.Tracker }
Options are the options used to create a new bandit
Click to show internal directories.
Click to hide internal directories.