lolly/internal/loadbalance/algorithms.go
xfy ec916d882d feat(proxy,middleware,config): 集成配置与代码差异修复
- 集成一致性哈希负载均衡到 proxy.go,支持 hash_key 和 virtual_nodes 配置
- 集成滑动窗口限流算法到 ratelimit.go,支持 algorithm 选择
- 应用 Transport 连接池配置到 createHostClient
- 集成 HSTS 配置到安全头部中间件
- 补充 config.example.yaml 缺失配置(http3、gzip_static、sliding_window)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-03 16:08:45 +08:00

25 lines
506 B
Go

// Package loadbalance 负载均衡包为 Lolly HTTP 服务器提供负载均衡算法。
package loadbalance
// ValidAlgorithms 是支持的负载均衡算法列表。
var ValidAlgorithms = []string{
"round_robin",
"weighted_round_robin",
"least_conn",
"ip_hash",
"consistent_hash",
}
// IsValidAlgorithm 检查算法是否有效。
func IsValidAlgorithm(alg string) bool {
if alg == "" {
return true
}
for _, a := range ValidAlgorithms {
if a == alg {
return true
}
}
return false
}