Documentation
¶
Index ¶
- Constants
- func BatchDelete(c *gin.Context, in *BatchDeleteRequest)
- func Create(c *gin.Context, in *SaveRequest)
- func Delete(c *gin.Context, in *UuidRequest)
- func Disable(c *gin.Context, in *UuidRequest)
- func Enable(c *gin.Context, in *UuidRequest)
- func List(c *gin.Context, in *ListRequest)
- func RecordTraffic(event TrafficEvent) time.Duration
- func RefreshRuntime()
- func RuntimeQuotaUsedMap() map[string]string
- func StartRuntime()
- func Update(c *gin.Context, in *SaveRequest)
- type BatchDeleteRequest
- type ListRequest
- type SaveRequest
- type TrafficEvent
- type UuidRequest
Constants ¶
View Source
const ( ScopeAll = "ALL" ScopeTag = "TAG" ScopeProxy = "PROXY" )
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(c *gin.Context, in *SaveRequest)
func Delete ¶
func Delete(c *gin.Context, in *UuidRequest)
func Disable ¶
func Disable(c *gin.Context, in *UuidRequest)
func Enable ¶
func Enable(c *gin.Context, in *UuidRequest)
func List ¶
func List(c *gin.Context, in *ListRequest)
func RecordTraffic ¶
func RecordTraffic(event TrafficEvent) time.Duration
RecordTraffic 记录真实代理出站流量,并返回当前流量包需要额外等待的时间。
高并发设计说明: 1. 热路径不使用全局锁,策略配置通过 atomic.Value 读取不可变快照; 2. 每条策略的配额、速率窗口、告警冷却时间均使用 atomic 计数; 3. 流量使用量现阶段只放在内存缓存中,不在代理热路径落库; 4. 告警写入通过非阻塞 channel 投递到异步 worker; 5. 没有匹配规则或未触发阈值时直接返回 0,不影响正常代理转发。
func RefreshRuntime ¶
func RefreshRuntime()
RefreshRuntime 同步刷新运行时快照。 用于服务启动、策略 CRUD、状态切换等低频路径;不在每次流量转发中调用。
func RuntimeQuotaUsedMap ¶
RuntimeQuotaUsedMap 返回当前运行时缓存中的配额使用量快照。
func StartRuntime ¶
func StartRuntime()
StartRuntime 在服务启动时预加载限速配额策略并启动异步 worker。 该函数不在代理转发热路径上,允许同步读取数据库。
func Update ¶
func Update(c *gin.Context, in *SaveRequest)
Types ¶
type BatchDeleteRequest ¶
type BatchDeleteRequest struct {
Uuids []string `json:"uuids" binding:"required"`
}
type ListRequest ¶
type SaveRequest ¶
type SaveRequest struct {
Uuid string `json:"uuid"`
Name string `json:"name" binding:"required"`
ScopeType string `json:"scope_type"`
ScopeValue string `json:"scope_value"`
OutboundLimit string `json:"outbound_limit"`
MaxConnections string `json:"max_connections"`
PeriodQuota string `json:"period_quota"`
OverLimitActionList []string `json:"over_limit_action_list"`
}
type TrafficEvent ¶
type UuidRequest ¶
type UuidRequest struct {
Uuid string `json:"uuid" binding:"required"`
}
Click to show internal directories.
Click to hide internal directories.