mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-12 04:06:37 +08:00
fix(gost): restore single-node bypass and preserve FailFilter backoff
Address reviewer feedback from PR #14 fix: 1. Single-node case: Bypass selector/FailFilter to ensure availability. This matches upstream go-gost/x behavior - single nodes should always be attempted regardless of recent failures. 2. Multi-node case: Preserve FailFilter's backoff contract. When all nodes are marked as failed, return nil to signal 'no healthy nodes' rather than falling back to a known-bad node. This prevents hammering unhealthy nodes and respects the failTimeout window. The handler's retry loop with ExcludeNodes context handles the multi-node failover properly - this change ensures hop.Select() provides correct information about node health status. Fixes intermittent forwarding failures introduced by #14.
This commit is contained in:
@@ -24,11 +24,12 @@ func FailFilter[T any](maxFails int, timeout time.Duration) selector.Filter[T] {
|
||||
}
|
||||
|
||||
// Filter filters dead objects.
|
||||
// Note: We intentionally do NOT skip filtering when len(vs) <= 1.
|
||||
// This ensures that even a single dead node gets filtered out,
|
||||
// allowing the caller to know that no healthy nodes are available
|
||||
// and potentially trigger failover behavior.
|
||||
// For single-node case, skip filtering to ensure availability (matches upstream).
|
||||
// For multi-node case, filter out failed nodes to enable failover.
|
||||
func (f *failFilter[T]) Filter(ctx context.Context, vs ...T) []T {
|
||||
if len(vs) <= 1 {
|
||||
return vs
|
||||
}
|
||||
var l []T
|
||||
for _, v := range vs {
|
||||
maxFails := f.maxFails
|
||||
|
||||
Reference in New Issue
Block a user