chore: rebuild provider load

This commit is contained in:
wwqgtxx
2025-05-12 22:19:49 +08:00
parent 6e35cf9399
commit 23e2d3a132
3 changed files with 34 additions and 85 deletions

View File

@@ -43,13 +43,14 @@ type HealthCheck struct {
}
func (hc *HealthCheck) process() {
if hc.started.Load() {
if !hc.started.CompareAndSwap(false, true) {
log.Warnln("Skip start health check timer due to it's started")
return
}
defer hc.started.Store(false)
ticker := time.NewTicker(hc.interval)
hc.start()
go hc.check()
for {
select {
case <-ticker.C:
@@ -62,7 +63,6 @@ func (hc *HealthCheck) process() {
}
case <-hc.ctx.Done():
ticker.Stop()
hc.stop()
return
}
}
@@ -131,14 +131,6 @@ func (hc *HealthCheck) touch() {
hc.lastTouch.Store(time.Now())
}
func (hc *HealthCheck) start() {
hc.started.Store(true)
}
func (hc *HealthCheck) stop() {
hc.started.Store(false)
}
func (hc *HealthCheck) check() {
if len(hc.proxies) == 0 {
return

View File

@@ -302,9 +302,6 @@ func (cp *compatibleProvider) Update() error {
}
func (cp *compatibleProvider) Initial() error {
if cp.healthCheck.interval != 0 && cp.healthCheck.url != "" {
cp.HealthCheck()
}
return nil
}