balance2

package
v0.0.0-...-2bf1368 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBalancer

func RegisterBalancer(name string, b Balancer)

Types

type Balancer

type Balancer interface {
	DoBalance([]*Instance, ...string) (*Instance, error)
}

type BalancerMgr

type BalancerMgr struct {
	// contains filtered or unexported fields
}
var Mgr *BalancerMgr = &BalancerMgr{
	allBalancer: make(map[string]Balancer, 0),
}

func (*BalancerMgr) RegisterBalancer

func (p *BalancerMgr) RegisterBalancer(name string, b Balancer)

type Instance

type Instance struct {
	Host string
	Port int
}

func DoBalance

func DoBalance(name string, insts []*Instance) (inst *Instance, err error)

func (*Instance) GetHost

func (p *Instance) GetHost() string

func (*Instance) GetPort

func (p *Instance) GetPort() int

func (*Instance) NewInstance

func (p *Instance) NewInstance(host string, port int)

func (*Instance) String

func (p *Instance) String() string

type RandomBalancer

type RandomBalancer struct {
}

func (*RandomBalancer) DoBalance

func (p *RandomBalancer) DoBalance(insts []*Instance, key ...string) (inst *Instance, err error)

type RoundBalancer

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

func (*RoundBalancer) DoBalance

func (p *RoundBalancer) DoBalance(insts []*Instance, key ...string) (inst *Instance, err error)

Jump to

Keyboard shortcuts

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