loadbalancer

package
v0.0.0-...-cde7464 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoadBalancer

type LoadBalancer struct {
	// contains filtered or unexported fields
}

LoadBalancer returns endpoints for downstream calls

func New

func New(strategy Strategy, endPoints []url.URL) *LoadBalancer

New creates a new loadbalancer and setting the given strategy

func (*LoadBalancer) GetEndpoint

func (l *LoadBalancer) GetEndpoint() url.URL

GetEndpoint gets an endpoint based on the given strategy

func (*LoadBalancer) UpdateEndpoints

func (l *LoadBalancer) UpdateEndpoints(urls []url.URL)

UpdateEndpoints updates the endpoints available to the strategy

type RandomStrategy

type RandomStrategy struct {
	// contains filtered or unexported fields
}

RandomStrategy implements Strategy for random endpoint selection

func (*RandomStrategy) NextEndpoint

func (rs *RandomStrategy) NextEndpoint() url.URL

NextEndpoint returns an endpoint using the random strategy

func (*RandomStrategy) SetEndpoints

func (rs *RandomStrategy) SetEndpoints(endpoints []url.URL)

SetEndpoints sets the available endpoints for use by the strategy

type RoundRobinStrategy

type RoundRobinStrategy struct {
	// contains filtered or unexported fields
}

RoundRobinStrategy implements Strategy for round robin endpoint selection

func (*RoundRobinStrategy) NextEndpoint

func (rrs *RoundRobinStrategy) NextEndpoint() url.URL

NextEndpoint returns an endpoint using the round robin strategy

func (*RoundRobinStrategy) SetEndpoints

func (rrs *RoundRobinStrategy) SetEndpoints(endpoints []url.URL)

SetEndpoints sets the available endpoints for use by the strategy

type Strategy

type Strategy interface {
	NextEndpoint() url.URL
	SetEndpoints([]url.URL)
}

Strategy is an interface to be implemented by loadbalancing strategies like round robin or random.

Jump to

Keyboard shortcuts

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