balance

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorInvalidBalance = errors.New("invalid balance")
)

Functions

func Keys

func Keys() []string

Keys 返回默认的balanceFactory注册器中所有已注册的key

func Register

func Register(key string, factory IBalanceFactory)

Register 注册balance工厂到默认balanceFactory注册器

Types

type IBalanceFactory

type IBalanceFactory interface {
	Create(app discovery.IApp) (IBalanceHandler, error)
}

IBalanceFactory 实现了负载均衡算法工厂

func Get

func Get(key string) (IBalanceFactory, bool)

Get 从默认balanceFactory注册器中获取balance工厂

func GetFactory

func GetFactory(name string) (IBalanceFactory, error)

GetFactory 获取指定负载均衡算法工厂,若指定的不存在则返回一个已注册的工厂

type IBalanceFactoryRegister

type IBalanceFactoryRegister interface {
	RegisterFactoryByKey(key string, factory IBalanceFactory)
	GetFactoryByKey(key string) (IBalanceFactory, bool)
	Keys() []string
}

IBalanceFactoryRegister 实现了负载均衡算法工厂管理器

type IBalanceHandler

type IBalanceHandler interface {
	Next() (discovery.INode, error)
}

IBalanceHandler 实现了负载均衡算法

Jump to

Keyboard shortcuts

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