platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
48
selective-vpn-api/app/transport_health_refresh_queue.go
Normal file
48
selective-vpn-api/app/transport_health_refresh_queue.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func transportHealthCandidate(item TransportClient) bool {
|
||||
if strings.TrimSpace(item.ID) == "" {
|
||||
return false
|
||||
}
|
||||
if !item.Enabled {
|
||||
return false
|
||||
}
|
||||
switch normalizeTransportStatus(item.Status) {
|
||||
case TransportClientUp, TransportClientStarting, TransportClientDegraded:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func transportQueueHealthProbe(item TransportClient, force bool) bool {
|
||||
now := time.Now()
|
||||
if !transportHealthSWR.begin(item, force, now) {
|
||||
return false
|
||||
}
|
||||
id := strings.TrimSpace(item.ID)
|
||||
if id == "" {
|
||||
transportHealthSWR.finishError(id, "missing client id", now)
|
||||
return false
|
||||
}
|
||||
go transportRunHealthProbe(id)
|
||||
return true
|
||||
}
|
||||
|
||||
func transportScheduleBackgroundHealthRefresh(known []TransportClient, targets []TransportClient) {
|
||||
if len(known) == 0 || len(targets) == 0 {
|
||||
return
|
||||
}
|
||||
transportHealthSWR.syncKnownClients(known)
|
||||
for _, it := range targets {
|
||||
if !transportHealthCandidate(it) {
|
||||
continue
|
||||
}
|
||||
transportQueueHealthProbe(it, false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user