remove invalidFilter for selector

This commit is contained in:
ginuerzh 2022-08-31 10:09:31 +08:00
parent 04b4a79b80
commit e77908a89e

View File

@ -2,8 +2,6 @@ package chain
import ( import (
"math/rand" "math/rand"
"net"
"strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@ -151,23 +149,3 @@ func (f *failFilter) Filter(nodes ...*Node) []*Node {
} }
return nl return nl
} }
type invalidFilter struct{}
// InvalidFilter filters the invalid node.
// A node is invalid if its port is invalid (negative or zero value).
func InvalidFilter() Filter {
return &invalidFilter{}
}
// Filter filters invalid nodes.
func (f *invalidFilter) Filter(nodes ...*Node) []*Node {
var nl []*Node
for _, node := range nodes {
_, sport, _ := net.SplitHostPort(node.Addr)
if port, _ := strconv.Atoi(sport); port > 0 {
nl = append(nl, node)
}
}
return nl
}