mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-01-03 17:46:36 +08:00
实现基础的IP地址阈值
This commit is contained in:
46
pkg/nodeconfigs/node_value_thresholds.go
Normal file
46
pkg/nodeconfigs/node_value_thresholds.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package nodeconfigs
|
||||
|
||||
import "github.com/iwind/TeaGo/maps"
|
||||
|
||||
type IPAddressThresholdItem = string
|
||||
|
||||
const (
|
||||
IPAddressThresholdItemAvgRequests IPAddressThresholdItem = "avgRequests"
|
||||
IPAddressThresholdItemAvgTrafficOut IPAddressThresholdItem = "avgTrafficOut" // M
|
||||
IPAddressThresholdItemAvgTrafficIn IPAddressThresholdItem = "avgTrafficIn" // M
|
||||
IPAddressThresholdItemConnectivity IPAddressThresholdItem = "connectivity" // 0-100
|
||||
)
|
||||
|
||||
// NodeValueThresholdConfig 阈值列表
|
||||
type NodeValueThresholdConfig struct {
|
||||
Id int64 `json:"id"`
|
||||
Items []*NodeValueThresholdItemConfig `json:"items"`
|
||||
Actions []*NodeValueThresholdActionConfig `json:"actions"`
|
||||
}
|
||||
|
||||
// NodeValueThresholdItemConfig 阈值项目
|
||||
type NodeValueThresholdItemConfig struct {
|
||||
Item NodeValueItem `json:"item"`
|
||||
Operator NodeValueOperator `json:"operator"`
|
||||
Value float64 `json:"value"`
|
||||
Duration int `json:"duration"`
|
||||
DurationUnit NodeValueDurationUnit `json:"durationUnit"`
|
||||
Options maps.Map `json:"options"` // 附加选项
|
||||
}
|
||||
|
||||
type NodeValueThresholdActionConfig struct {
|
||||
Action string `json:"action"`
|
||||
Options maps.Map `json:"options"`
|
||||
}
|
||||
|
||||
// NodeValueThresholdAction 动作
|
||||
type NodeValueThresholdAction = string
|
||||
|
||||
const (
|
||||
NodeValueThresholdActionUp NodeValueThresholdAction = "up" // 上线
|
||||
NodeValueThresholdActionDown NodeValueThresholdAction = "down" // 下线
|
||||
NodeValueThresholdActionNotify NodeValueThresholdAction = "notify" // 通知
|
||||
NodeValueThresholdActionSwitch NodeValueThresholdAction = "switch" // 切换到备用IP
|
||||
)
|
||||
Reference in New Issue
Block a user