platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
37
selective-vpn-api/app/transport_health_refresh.go
Normal file
37
selective-vpn-api/app/transport_health_refresh.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
transportHealthFreshTTL = 45 * time.Second
|
||||
transportHealthBackoffMin = 5 * time.Second
|
||||
transportHealthBackoffMax = 2 * time.Minute
|
||||
transportHealthPersistMinAge = 90 * time.Second
|
||||
transportHealthMaxConcurrentProbe = 2
|
||||
)
|
||||
|
||||
type transportHealthRefreshEntry struct {
|
||||
swr refreshCoordinator
|
||||
}
|
||||
|
||||
type transportHealthRefresher struct {
|
||||
mu sync.Mutex
|
||||
entries map[string]*transportHealthRefreshEntry
|
||||
sem chan struct{}
|
||||
}
|
||||
|
||||
func newTransportHealthRefresher(maxConcurrent int) *transportHealthRefresher {
|
||||
n := maxConcurrent
|
||||
if n <= 0 {
|
||||
n = transportHealthMaxConcurrentProbe
|
||||
}
|
||||
return &transportHealthRefresher{
|
||||
entries: map[string]*transportHealthRefreshEntry{},
|
||||
sem: make(chan struct{}, n),
|
||||
}
|
||||
}
|
||||
|
||||
var transportHealthSWR = newTransportHealthRefresher(envInt("SVPN_TRANSPORT_HEALTH_MAX_PARALLEL", transportHealthMaxConcurrentProbe))
|
||||
Reference in New Issue
Block a user