lbtransport

package
v1.0.0-alpha.test.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaximumRefreshInterval decides the maximum sleep time between SRV Lookups, otherwise controlled by TTL of records.
	MaximumRefreshInterval = 5 * time.Second
	// ExpirationMargin, the margin before the TTL expiration on which we should re-resolve.
	ExpirationMargin = 50 * time.Millisecond
)

Functions

func New

func New(targetAddr string, parent http.RoundTripper, resolver naming.Resolver, policy LBPolicy) (*tripper, error)

New creates a new load-balanced Round Tripper for a single backend.

This RoundTripper is meant to only dial a single backend, and will throw errors if the req.URL.Host doesn't match the targetAddr.

For resolving backend addresses it uses a grpc.naming.Resolver, allowing for generic use.

Types

type LBPolicy

type LBPolicy interface {
	// Pick decides on which target to use for the request out of the provided ones.
	Pick(req *http.Request, currentTargets []*Target) (*Target, error)
}

LBPolicy decides which target to pick for a given call.

func RoundRobinPolicy

func RoundRobinPolicy(backoffDuration time.Duration, dialTimeout time.Duration) LBPolicy

func RoundRobinPolicyFromFlags

func RoundRobinPolicyFromFlags() LBPolicy

type Target

type Target struct {
	DialAddr string
}

Target represents the canonical address of a backend.

Jump to

Keyboard shortcuts

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