balance

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 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 Balancer

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

func New

func New(schedule Scheduler, instances []*Instance) *Balancer

func (*Balancer) Pick

func (b *Balancer) Pick(partition int64) *Instance

type Instance

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

func NewInstance

func NewInstance(v interface{}, score int32) *Instance

func (*Instance) Score

func (ins *Instance) Score() int32

> 0 healthy; < 0 unhealthy; == 0 unknown, more high score more health, can also use as weight

func (*Instance) Update

func (ins *Instance) Update(v interface{}, score int32)

func (*Instance) UpdateScore

func (ins *Instance) UpdateScore(score int32)

func (*Instance) UpdateValue

func (ins *Instance) UpdateValue(v interface{})

func (*Instance) Value

func (ins *Instance) Value() interface{}

type RoundRobin

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

scheduler implement

func (*RoundRobin) Pick

func (rr *RoundRobin) Pick(partition int64, total int) int

func (*RoundRobin) UpdateStatus

func (rr *RoundRobin) UpdateStatus(index int, score int32)

type Scheduler

type Scheduler interface {
	// return < 0 means no instance available
	Pick(partition int64, total int) int
	UpdateStatus(index int, score int32)
}

Jump to

Keyboard shortcuts

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