balance

package
v0.0.0-...-014b5c3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(sniConf *config.Sni, balance string) core.Balancer

*

  • Create new Balancer based on balancing strategy
  • Wrap it in middlewares if needed

Types

type Iphash1Balancer

type Iphash1Balancer struct {
}

*

  • Iphash balancer

func (*Iphash1Balancer) Elect

func (b *Iphash1Balancer) Elect(context core.Context, backends []*core.Backend) (*core.Backend, error)

*

  • Elect backend using semi-consistent iphash strategy. This is naive implementation
  • using Key+Node Hash Algorithm for stable sharding described at http://kennethxu.blogspot.com/2012/11/sharding-algorithm.html
  • It survives removing nodes (removing stability), so that clients connected to backends that have not been removed stay
  • untouched. *

type IphashBalancer

type IphashBalancer struct{}

*

  • Iphash balancer

func (*IphashBalancer) Elect

func (b *IphashBalancer) Elect(context core.Context, backends []*core.Backend) (*core.Backend, error)

*

  • Elect backend using iphash strategy
  • Using fnv1a for speed *
  • TODO: Improve as needed

type LeastbandwidthBalancer

type LeastbandwidthBalancer struct{}

*

  • Leastbandwidth balancer

func (*LeastbandwidthBalancer) Elect

func (b *LeastbandwidthBalancer) Elect(context core.Context, backends []*core.Backend) (*core.Backend, error)

*

  • Elect backend using leastbandwidth strategy

type LeastconnBalancer

type LeastconnBalancer struct{}

*

  • Leastconn balancer

func (*LeastconnBalancer) Elect

func (b *LeastconnBalancer) Elect(context core.Context, backends []*core.Backend) (*core.Backend, error)

*

  • Elect backend using roundrobin strategy

type RoundrobinBalancer

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

*

  • Roundrobin balancer

func (*RoundrobinBalancer) Elect

func (b *RoundrobinBalancer) Elect(context core.Context, backends []*core.Backend) (*core.Backend, error)

*

  • Elect backend using roundrobin strategy

type WeightBalancer

type WeightBalancer struct{}

*

  • Weight balancer

func (*WeightBalancer) Elect

func (b *WeightBalancer) Elect(context core.Context, backends []*core.Backend) (*core.Backend, error)

*

  • Elect backend based on weight strategy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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