fix(proxy,config): 修复 HealthChecker 重启支持和补充 random 算法文档
Stop 后重建 stopCh 以支持再次 Start;config 注释补充 random 算法。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
11f9cebcd5
commit
8baee13503
@ -319,7 +319,7 @@ type StaticConfig struct {
|
||||
// 注意事项:
|
||||
// - Path 使用前缀匹配,较长路径优先匹配
|
||||
// - 至少配置一个 Target 才能正常工作
|
||||
// - 负载均衡算法支持:round_robin、weighted_round_robin、least_conn、ip_hash、consistent_hash
|
||||
// - 负载均衡算法支持:round_robin、weighted_round_robin、least_conn、ip_hash、consistent_hash、random
|
||||
// - 一致性哈希需要配置 HashKey
|
||||
//
|
||||
// 使用示例:
|
||||
|
||||
@ -120,11 +120,14 @@ func (h *HealthChecker) Start() {
|
||||
// Stop 停止后台健康检查进程。
|
||||
// 它向后台 goroutine 发送停止信号并等待其完成。
|
||||
// Stop 是幂等的;在已停止的检查器上调用它不会产生任何效果。
|
||||
// Stop 后可以再次调用 Start 重新启动检查器。
|
||||
func (h *HealthChecker) Stop() {
|
||||
if !h.running.CompareAndSwap(true, false) {
|
||||
return // 已经停止,直接返回
|
||||
}
|
||||
close(h.stopCh)
|
||||
// 重新创建 stopCh 以支持后续 Start
|
||||
h.stopCh = make(chan struct{})
|
||||
}
|
||||
|
||||
// run 是在后台 goroutine 中运行的主要健康检查循环。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user