Reworks urltest round_robin to scale to large node lists. v1 rotated over ALL live nodes,
which meant URL-testing every node each interval (unworkable at 1000 nodes). v2:
- Fixed-size pool of slots (balancer.pool, default 3). Slot indices never move; a
replacement takes the exact slot it evicts. round_robin rotates only within the pool.
- Lazy health-check: pool_tolerance=0 tests no more nodes than needed to keep the pool
full of live nodes, then stops; pool_tolerance>0 tests all and keeps the fastest with a
per-slot eviction threshold. Dead pool node keeps its slot until a live replacement is
found (pool never empties). A dial error never changes the pool — only the health-check.
- sticky = slot-hash (slot[hash(key)%pool], FNV-64a). Binds to a fixed slot index, so a
living node keeps ALL its keys when other slots churn: strict zero reconnects, zero
per-key state. Default sticky_hash ["process","domain"]; explicit [] disables.
- Removes v1 jumphash (broke on mid-list eviction), ttl_map, and least_connection (dropped
from the roadmap — round_robin is statistically even).
- GetPool RPC: CommandClient.GetPool(tag) -> []PoolSlot{slot,tag,delay} so clients can show
the N nodes actually in rotation. delay clamped 0->1 for live nodes; non-round_robin
group -> empty. Additive proto/daemon/libbox, behind with_lx_command.
Config moved under a `balancer` object (breaking for the rc.11/12 round_robin shape; no
prod configs, tests only). least_test (default) is byte-for-byte unchanged.
Tests: newBalancer validation/defaults, rotation distribution, slot-hash stable +
living-node-keeps-keys-across-other-slot-churn, empty-key fixed slot, planTolerantPool
top-N / keep-in-tolerance / evict-beyond / dead-slot-replace. go build (+with_lx_command),
go test -race ./protocol/group/, gofmt all clean. Not yet device-verified.
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package constant
|
|
|
|
import "time"
|
|
|
|
const (
|
|
TCPKeepAliveInitial = 5 * time.Minute
|
|
TCPKeepAliveInterval = 75 * time.Second
|
|
TCPConnectTimeout = 5 * time.Second
|
|
TCPTimeout = 15 * time.Second
|
|
ReadPayloadTimeout = 300 * time.Millisecond
|
|
DNSTimeout = 10 * time.Second
|
|
UDPTimeout = 5 * time.Minute
|
|
ICMPTimeout = 10 * time.Second
|
|
DefaultURLTestInterval = 3 * time.Minute
|
|
DefaultURLTestIdleTimeout = 30 * time.Minute
|
|
StartTimeout = 10 * time.Second
|
|
StopTimeout = 5 * time.Second
|
|
FatalStopTimeout = 10 * time.Second
|
|
FakeIPMetadataSaveInterval = 10 * time.Second
|
|
TLSFragmentFallbackDelay = 500 * time.Millisecond
|
|
)
|
|
|
|
var PortProtocols = map[uint16]string{
|
|
53: ProtocolDNS,
|
|
123: ProtocolNTP,
|
|
3478: ProtocolSTUN,
|
|
443: ProtocolQUIC,
|
|
}
|
|
|
|
var ProtocolTimeouts = map[string]time.Duration{
|
|
ProtocolDNS: 10 * time.Second,
|
|
ProtocolNTP: 10 * time.Second,
|
|
ProtocolSTUN: 10 * time.Second,
|
|
ProtocolQUIC: 30 * time.Second,
|
|
ProtocolDTLS: 30 * time.Second,
|
|
}
|