Documentation
¶
Index ¶
- Variables
- func Prettify(i interface{}) string
- func String(v string) *string
- func StringValue(v *string) string
- type BalanceZone
- type CDFactors
- type CDInstanceFactor
- type CDZoneCPU
- type Config
- type Consul
- type CrossZone
- type DataInstanceFactor
- type GlobalConfig
- type GlobalService
- type InitialWeight
- type InstanceLoad
- type Lab
- type LearningFactors
- type Logic
- type LogicConfig
- type MockWorkload
- type OnlineLab
- type Service
- type ServiceNode
- type WeightLearner
- func (wl *WeightLearner) Clear(consul *Consul) error
- func (wl *WeightLearner) Fetch(consul *Consul) error
- func (wl *WeightLearner) GetLearningFactors() *LearningFactors
- func (wl *WeightLearner) LearningCrossRate(workload Workload, ol *OnlineLab) error
- func (wl *WeightLearner) LearningFactors(service *Service, workload Workload, ol *OnlineLab) error
- func (wl *WeightLearner) RiskControl(initWeight *InitialWeight)
- func (wl *WeightLearner) Update(consul *Consul) error
- type Workload
- type WorkloadCPU
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorConsulKeyNotExist = errors.New("key not exist")
Functions ¶
func Prettify ¶
func Prettify(i interface{}) string
Prettify returns the string representation of a value.
func StringValue ¶
StringValue returns the value of the string pointer passed in or "" if the pointer is nil.
Types ¶
type BalanceZone ¶
type BalanceZone struct { Enabled bool `json:"enabled"` LearningRate float64 `json:"learningRate"` LearningThreshold float64 `json:"learningThreshold"` }
管理节点间均衡参数
type CDFactors ¶
type CDFactors struct { Updated int64 `json:"updated"` Data []*CDInstanceFactor `json:"data"` }
type CDInstanceFactor ¶
type CDZoneCPU ¶
type CDZoneCPU struct { Updated int64 `json:"updated"` Data []interface{} `json:"data"` }
type Config ¶
type Config struct { Global *GlobalConfig `json:"global"` Logic []*LogicConfig `json:"logic"` }
type Consul ¶
type Consul struct {
// contains filtered or unexported fields
}
func (*Consul) GetService ¶
func (c *Consul) GetService(service string) ([]*api.ServiceEntry, error)
包装一下,不需要meta,只要健康的节点
type CrossZone ¶
type CrossZone struct { AlarmThreshold float64 `json:"alarmThreshold"` CrossRate float64 `json:"crossRate"` Enabled bool `json:"enabled"` LearningRate float64 `json:"learningRate"` LearningThreshold float64 `json:"learningThreshold"` }
管理跨区域的均衡参数
type DataInstanceFactor ¶
type DataInstanceFactor struct { }
type GlobalConfig ¶
type InitialWeight ¶
func NewInitialWeight ¶
func NewInitialWeight() *InitialWeight
func (*InitialWeight) Fetch ¶
func (iw *InitialWeight) Fetch(service *Service)
func (*InitialWeight) Unhealthy ¶
func (iw *InitialWeight) Unhealthy(factors LearningFactors) []string
计算learning权重和初始化权重,返回确认有风险的实例 TODO:通过计算方差或人工限定的阈值防止风险
type InstanceLoad ¶
type Lab ¶
type Lab struct { BalanceZone BalanceZone `json:"balanceZone"` CrossZone CrossZone `json:"crossZone"` }
type LearningFactors ¶
type Logic ¶
type Logic struct { Consul *Consul InitialWeight *InitialWeight OnlineLab *OnlineLab Service *Service WeightLearner *WeightLearner ServiceName string Workload Workload // interface support other workload // contains filtered or unexported fields }
func NewLearningLogic ¶
func NewLearningLogic(logicCfg *LogicConfig, globalCfg *GlobalConfig) *Logic
func (*Logic) RunningLoop ¶
type LogicConfig ¶
type MockWorkload ¶
type MockWorkload struct { }
Mock一个负载对象用于快速开发测试
func (*MockWorkload) Fetch ¶
func (wl *MockWorkload) Fetch(consul *Consul) error
func (*MockWorkload) GetInstanceLoad ¶
func (wl *MockWorkload) GetInstanceLoad() []*InstanceLoad
func (*MockWorkload) GetZoneLoad ¶
func (wl *MockWorkload) GetZoneLoad() map[string]float64
type OnlineLab ¶
type OnlineLab struct {
// contains filtered or unexported fields
}
func (*OnlineLab) DefaultLab ¶
func (ol *OnlineLab) DefaultLab()
设置默认的lab,方便测试和初期上线,或紧急恢复等等 这里一定要设置安全的值
type Service ¶
type Service struct { Name string Nodes map[string]*ServiceNode Zones map[string][]*ServiceNode Region string }
Manage a service, every service manage many zones
type ServiceNode ¶
Better to use a struct to manage node detail Data filled when reading consul key
type WeightLearner ¶
type WeightLearner struct { Key string Factors *LearningFactors InitialWeight *InitialWeight }
Weight factor should learn from workload 用一个模型来管理权重与学习方法便于升级维护 初始化的权重用于控制实时学习权重的偏离风险,明显偏离太多是有可能发生了bug,需要控制一下
func NewWeightLearner ¶
func NewWeightLearner(key string) *WeightLearner
func (*WeightLearner) Clear ¶
func (wl *WeightLearner) Clear(consul *Consul) error
func (*WeightLearner) Fetch ¶
func (wl *WeightLearner) Fetch(consul *Consul) error
func (*WeightLearner) GetLearningFactors ¶
func (wl *WeightLearner) GetLearningFactors() *LearningFactors
func (*WeightLearner) LearningCrossRate ¶
func (wl *WeightLearner) LearningCrossRate(workload Workload, ol *OnlineLab) error
func (*WeightLearner) LearningFactors ¶
func (wl *WeightLearner) LearningFactors(service *Service, workload Workload, ol *OnlineLab) error
func (*WeightLearner) RiskControl ¶
func (wl *WeightLearner) RiskControl(initWeight *InitialWeight)
func (*WeightLearner) Update ¶
func (wl *WeightLearner) Update(consul *Consul) error
type Workload ¶
type Workload interface { Fetch(consul *Consul) error GetInstanceLoad() []*InstanceLoad GetZoneLoad() map[string]float64 }
type WorkloadCPU ¶
type WorkloadCPU struct {
// contains filtered or unexported fields
}
func NewWorkloadCPU ¶
func NewWorkloadCPU(instanceLoadKey string, zoneLoadKey string) *WorkloadCPU
func (*WorkloadCPU) Fetch ¶
func (wl *WorkloadCPU) Fetch(consul *Consul) error
func (*WorkloadCPU) GetInstanceLoad ¶
func (wl *WorkloadCPU) GetInstanceLoad() []*InstanceLoad
func (*WorkloadCPU) GetZoneLoad ¶
func (wl *WorkloadCPU) GetZoneLoad() map[string]float64
Click to show internal directories.
Click to hide internal directories.