balancer

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BALANCEFACTOR_MAX_LOCAL   = 3000
	BALANCEFACTOR_MIN_LOCAL   = 200
	BALANCEFACTOR_MAX_CROSS   = 1000
	BALANCEFACTOR_MIN_CROSS   = 1
	BALANCEFACTOR_START_CROSS = 50
	BALANCEFACTOR_CROSS_RATE  = 0.1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUThreshold

type CPUThreshold struct {
	CThreshold float64 `json:"cpuThreshold"`
}

type CandidatePool

type CandidatePool struct {
	Nodes     []*ServiceNode
	Factors   []float64
	Weights   []float64
	FactorSum float64
}

type ConsulClient

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

func NewConsulClient

func NewConsulClient(address string) (*ConsulClient, error)

func (*ConsulClient) Get

func (c *ConsulClient) Get(key string) ([]byte, error)

func (*ConsulClient) GetServiceNodes

func (c *ConsulClient) GetServiceNodes(service, tag string, passingOnly bool) ([]ServiceNode, error)

func (*ConsulClient) Put

func (c *ConsulClient) Put(key string, val []byte) error

type ConsulResolver

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

func NewConsulResolver

func NewConsulResolver(cloud, address, service, cpuThresholdKey, zoneCPUKey, instanceFactorKey, onlineLabKey string, interval, timeout time.Duration, args ...string) (*ConsulResolver, error)

func (*ConsulResolver) GetZoneNodes added in v0.0.4

func (r *ConsulResolver) GetZoneNodes(zone string) []*ServiceNode

func (*ConsulResolver) SelectNode

func (r *ConsulResolver) SelectNode() *ServiceNode

func (*ConsulResolver) SetLogger

func (r *ConsulResolver) SetLogger(logger util.Logger)

func (*ConsulResolver) SetWatcher added in v0.0.7

func (r *ConsulResolver) SetWatcher(watcherLogger util.Logger)

func (*ConsulResolver) SetZone

func (r *ConsulResolver) SetZone(zone string)

func (*ConsulResolver) Start

func (r *ConsulResolver) Start() error

func (*ConsulResolver) Stop

func (r *ConsulResolver) Stop()

type ConsulResolverBuilder

type ConsulResolverBuilder struct {
	Cloud             string
	Address           string
	Service           string
	CPUThresholdKey   string
	ZoneCPUKey        string
	InstanceFactorKey string
	OnlineLabKey      string
	Interval          time.Duration
	Timeout           time.Duration
}

func (*ConsulResolverBuilder) Build

type ConsulResolverMetric

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

type InstanceFactor

type InstanceFactor struct {
	Updated int64              `json:"updated"`
	Date    []InstanceMetaInfo `json:"data"`
}

type InstanceMetaInfo

type InstanceMetaInfo struct {
	PublicIP       string  `json:"public_ip"`
	InstanceID     string  `json:"instanceid"`
	CPUUtilization float64 `json:"CPUUtilization"`
	Zone           string  `json:"zone"`
}

type OnlineLab

type OnlineLab struct {
	CrossZone         bool    `json:"crossZone"`
	CrossZoneRate     float64 `json:"crossZoneRate"` // TODO
	FactorCacheExpire int     `json:"factorCacheExpire"`
	FactorStartRate   float64 `json:"factorStartRate"`
	LearningRate      float64 `json:"learningRate"`
	RateThreshold     float64 `json:"rateThreshold"`
}

type ServiceNode

type ServiceNode struct {
	PublicIP      string
	InstanceID    string
	Host          string
	Port          int
	Zone          string
	BalanceFactor float64
	CurrentFactor float64
	WorkLoad      float64
}

type ServiceNodes added in v0.1.7

type ServiceNodes struct {
	UpdateTime int64
	Data       []ServiceNode
}

type ServiceZone

type ServiceZone struct {
	Nodes    []*ServiceNode
	Zone     string
	WorkLoad float64
}

type ZoneCPUUtilizationRatio

type ZoneCPUUtilizationRatio struct {
	Updated int64                `json:"updated"`
	Date    []map[string]float64 `json:"data"`
}

Jump to

Keyboard shortcuts

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