selector

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// when query upstream timeout, usually upstream is unavailable for a long time.
	Timeout upstreamStatus = iota

	// when query upstream return 5xx response, upstream still alive, maybe just a lof of query for him.
	Error

	// when query upstream ok, means upstream is available.
	OK
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugReporter

type DebugReporter interface {
	// ReportWeights starts a goroutine to report all upstream weights, recommend interval is 15s
	ReportWeights()
}

type LVSWRRSelector

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

func NewLVSWRRSelector

func NewLVSWRRSelector(timeout time.Duration) *LVSWRRSelector

func (*LVSWRRSelector) Add

func (ls *LVSWRRSelector) Add(url string, upstreamType UpstreamType, weight int32) (err error)

func (*LVSWRRSelector) Get

func (ls *LVSWRRSelector) Get() *Upstream

func (*LVSWRRSelector) ReportUpstreamStatus

func (ls *LVSWRRSelector) ReportUpstreamStatus(upstream *Upstream, upstreamStatus upstreamStatus)

func (*LVSWRRSelector) ReportWeights

func (ls *LVSWRRSelector) ReportWeights()

func (*LVSWRRSelector) StartEvaluate

func (ls *LVSWRRSelector) StartEvaluate()

type NginxWRRSelector

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

func NewNginxWRRSelector

func NewNginxWRRSelector(timeout time.Duration) *NginxWRRSelector

func (*NginxWRRSelector) Add

func (ws *NginxWRRSelector) Add(url string, upstreamType UpstreamType, weight int32) (err error)

func (*NginxWRRSelector) Get

func (ws *NginxWRRSelector) Get() *Upstream

nginx wrr like.

func (*NginxWRRSelector) ReportUpstreamStatus

func (ws *NginxWRRSelector) ReportUpstreamStatus(upstream *Upstream, upstreamStatus upstreamStatus)

func (*NginxWRRSelector) ReportWeights

func (ws *NginxWRRSelector) ReportWeights()

func (*NginxWRRSelector) StartEvaluate

func (ws *NginxWRRSelector) StartEvaluate()

type RandomSelector

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

func NewRandomSelector

func NewRandomSelector() *RandomSelector

func (*RandomSelector) Add

func (rs *RandomSelector) Add(url string, upstreamType UpstreamType) (err error)

func (*RandomSelector) Get

func (rs *RandomSelector) Get() *Upstream

func (*RandomSelector) ReportUpstreamStatus

func (rs *RandomSelector) ReportUpstreamStatus(upstream *Upstream, upstreamStatus upstreamStatus)

func (*RandomSelector) StartEvaluate

func (rs *RandomSelector) StartEvaluate()

type Selector

type Selector interface {
	// Get returns a upstream
	Get() *Upstream

	// StartEvaluate start upstream evaluation loop
	StartEvaluate()

	// ReportUpstreamStatus report upstream status
	ReportUpstreamStatus(upstream *Upstream, upstreamStatus upstreamStatus)
}

type Upstream

type Upstream struct {
	Type        UpstreamType
	URL         string
	RequestType string
	// contains filtered or unexported fields
}

func (Upstream) String

func (u Upstream) String() string

type UpstreamType

type UpstreamType int
const (
	Google UpstreamType = iota
	IETF
)

Jump to

Keyboard shortcuts

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