lbtransport

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

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

Go to latest
Published: Sep 5, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, 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 {
	// Picker returns PolicyPicker that is suitable to be used within single request.
	Picker() LBPolicyPicker
}

func RoundRobinPolicy

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

func RoundRobinPolicyFromFlags

func RoundRobinPolicyFromFlags() LBPolicy

type LBPolicyPicker

type LBPolicyPicker interface {
	// Pick decides on which target to use for the request out of the provided ones.
	Pick(req *http.Request, currentTargets []*Target) (*Target, error)
	// ExcludeHost excludes the given target for a short time. It is useful to report no connection (even temporary).
	ExcludeTarget(*Target)
}

LBPolicyPicker decides which target to pick for a given call. Should be short-living.

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