lb

package
Version: v0.0.0-...-b9d6073 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package lb is default LoadBalance implements.

Index

Constants

View Source
const (
	Random     = "random"
	Roundrobin = "roundrobin"
)

ext name

View Source
const (
	MaxSelectArraySize = 3
)

Variables

This section is empty.

Functions

func NewWeightLbFunc

func NewWeightLbFunc(newLb motan.NewLbFunc) motan.NewLbFunc

func RegistDefaultLb

func RegistDefaultLb(extFactory motan.ExtentionFactory)

func SelectArrayFromIndex

func SelectArrayFromIndex(endpoints []motan.EndPoint, fromIndex int) []motan.EndPoint

func SelectOneAtRandom

func SelectOneAtRandom(endpoints []motan.EndPoint) (int, motan.EndPoint)

SelectOneAtRandom to prevent put pressure to the next node when a node being unavailable, then need to do two random

Types

type RandomLB

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

func (*RandomLB) OnRefresh

func (r *RandomLB) OnRefresh(endpoints []motan.EndPoint)

func (*RandomLB) Select

func (r *RandomLB) Select(request motan.Request) motan.EndPoint

func (*RandomLB) SelectArray

func (r *RandomLB) SelectArray(request motan.Request) []motan.EndPoint

func (*RandomLB) SetWeight

func (r *RandomLB) SetWeight(weight string)

type RoundrobinLB

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

func (*RoundrobinLB) OnRefresh

func (r *RoundrobinLB) OnRefresh(endpoints []motan.EndPoint)

func (*RoundrobinLB) Select

func (r *RoundrobinLB) Select(request motan.Request) motan.EndPoint

func (*RoundrobinLB) SelectArray

func (r *RoundrobinLB) SelectArray(request motan.Request) []motan.EndPoint

func (*RoundrobinLB) SetWeight

func (r *RoundrobinLB) SetWeight(weight string)

type WeightedLbWraper

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

WeightedLbWraper support multi group weighted LB

func (*WeightedLbWraper) OnRefresh

func (w *WeightedLbWraper) OnRefresh(endpoints []motan.EndPoint)

func (*WeightedLbWraper) Select

func (w *WeightedLbWraper) Select(request motan.Request) motan.EndPoint

func (*WeightedLbWraper) SelectArray

func (w *WeightedLbWraper) SelectArray(request motan.Request) []motan.EndPoint

func (*WeightedLbWraper) SetWeight

func (w *WeightedLbWraper) SetWeight(weight string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL