loadbalancer

package
v0.0.0-...-0fc3184 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrNoEndpointsAvailable is given by a load balancer when no endpoints are available to be returned.

Functions

func Retry

func Retry(max int, timeout time.Duration, lb LoadBalancer) endpoint.Endpoint

Retry yields an endpoint that takes endpoints from the load balancer. Invocations that return errors will be retried until they succeed, up to max times, or until the timeout is elapsed, whichever comes first.

Types

type LoadBalancer

type LoadBalancer interface {
	Get() (endpoint.Endpoint, error)
}

LoadBalancer yields endpoints one-by-one.

func Random

func Random(p Publisher) LoadBalancer

Random returns a load balancer that yields random endpoints.

func RoundRobin

func RoundRobin(p Publisher) LoadBalancer

RoundRobin returns a load balancer that yields endpoints in sequence.

type Publisher

type Publisher interface {
	Subscribe(chan<- []endpoint.Endpoint)
	Unsubscribe(chan<- []endpoint.Endpoint)
	Stop()
}

Publisher produces endpoints.

func NewDNSSRVPublisher

func NewDNSSRVPublisher(name string, ttl time.Duration, makeEndpoint func(hostport string) endpoint.Endpoint) Publisher

NewDNSSRVPublisher returns a publisher that resolves the SRV name every ttl, and

type StaticPublisher

type StaticPublisher struct {
	sync.Mutex
	// contains filtered or unexported fields
}

StaticPublisher holds a static set of endpoints.

func NewStaticPublisher

func NewStaticPublisher(endpoints []endpoint.Endpoint) *StaticPublisher

NewStaticPublisher returns a publisher that yields a static set of endpoints, which can be completely replaced.

func (*StaticPublisher) Replace

func (p *StaticPublisher) Replace(endpoints []endpoint.Endpoint)

Replace replaces the endpoints and notifies all subscribers.

func (*StaticPublisher) Stop

func (p *StaticPublisher) Stop()

Stop implements Publisher, but is a no-op.

func (*StaticPublisher) Subscribe

func (p *StaticPublisher) Subscribe(c chan<- []endpoint.Endpoint)

Subscribe implements Publisher.

func (*StaticPublisher) Unsubscribe

func (p *StaticPublisher) Unsubscribe(c chan<- []endpoint.Endpoint)

Unsubscribe implements Publisher.

Jump to

Keyboard shortcuts

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