lbtransport

package
v0.1.1-rc.6-body-doubl... Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: Apache-2.0 Imports: 18 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(ctx context.Context, backoffDuration time.Duration, dialTimeout time.Duration) LBPolicy

func RoundRobinPolicyFromFlags

func RoundRobinPolicyFromFlags(ctx context.Context) 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