Refactor healthcheck sender and receiver to use configurable options (#4433)

This commit is contained in:
Zoltan Papp
2025-09-12 09:31:03 +02:00
committed by GitHub
parent cf7f6c355f
commit 0c6f671a7c
10 changed files with 186 additions and 176 deletions
+8 -10
View File
@@ -13,11 +13,8 @@ import (
)
const (
maxConcurrentServers = 7
)
var (
connectionTimeout = 30 * time.Second
maxConcurrentServers = 7
defaultConnectionTimeout = 30 * time.Second
)
type connResult struct {
@@ -27,14 +24,15 @@ type connResult struct {
}
type ServerPicker struct {
TokenStore *auth.TokenStore
ServerURLs atomic.Value
PeerID string
MTU uint16
TokenStore *auth.TokenStore
ServerURLs atomic.Value
PeerID string
MTU uint16
ConnectionTimeout time.Duration
}
func (sp *ServerPicker) PickServer(parentCtx context.Context) (*Client, error) {
ctx, cancel := context.WithTimeout(parentCtx, connectionTimeout)
ctx, cancel := context.WithTimeout(parentCtx, sp.ConnectionTimeout)
defer cancel()
totalServers := len(sp.ServerURLs.Load().([]string))