package lb

import "github.com/go-kit/kit/sd/lb"

Package lb implements the client-side load balancer pattern. 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

Variables

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.

Source Files

balancer.go doc.go random.go retry.go round_robin.go

Version
v0.2.0
Published
Jul 27, 2016
Platform
js/wasm
Imports
9 packages
Last checked
4 days ago

Tools for package owners.