lb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package lb deals with client-side load balancing across multiple identical instances of services and endpoints. When combined with a service discovery system of record, it enables a more decentralized architecture, removing the need for separate load balancers like HAProxy.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEndpoints = errors.New("no endpoints available")

ErrNoEndpoints is returned when no qualifying endpoints are available.

Functions

func Retry

func Retry(max int, timeout time.Duration, b Balancer) endpoint.Endpoint

Retry wraps a service load balancer and returns an endpoint oriented load balancer for the specified service method. Requests to the endpoint will be automatically load balanced via the load balancer. Requests that return errors will be retried until they succeed, up to max times, or until the timeout is elapsed, whichever comes first.

Types

type Balancer

type Balancer interface {
	Endpoint() (endpoint.Endpoint, error)
}

Balancer yields endpoints according to some heuristic.

func NewRandom

func NewRandom(s sd.Subscriber, seed int64) Balancer

NewRandom returns a load balancer that selects services randomly.

func NewRoundRobin

func NewRoundRobin(s sd.Subscriber) Balancer

NewRoundRobin returns a load balancer that returns services in sequence.

Jump to

Keyboard shortcuts

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