add weight for selector
This commit is contained in:
@ -10,7 +10,6 @@ import (
|
||||
tls_util "github.com/go-gost/x/internal/util/tls"
|
||||
"github.com/go-gost/x/metadata"
|
||||
"github.com/go-gost/x/registry"
|
||||
xs "github.com/go-gost/x/selector"
|
||||
)
|
||||
|
||||
func ParseChain(cfg *config.ChainConfig) (chain.SelectableChainer, error) {
|
||||
@ -142,7 +141,7 @@ func ParseChain(cfg *config.ChainConfig) (chain.SelectableChainer, error) {
|
||||
sel = s
|
||||
}
|
||||
if sel == nil {
|
||||
sel = xs.DefaultNodeSelector
|
||||
sel = defaultNodeSelector()
|
||||
}
|
||||
group.WithSelector(sel).
|
||||
WithBypass(bypass.BypassGroup(bypassList(hop.Bypass, hop.Bypasses...)...))
|
||||
|
@ -298,3 +298,11 @@ func ParseRecorder(cfg *config.RecorderConfig) (r recorder.Recorder) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func defaultNodeSelector() selector.Selector[*chain.Node] {
|
||||
return xs.NewSelector(xs.RoundRobinStrategy[*chain.Node]())
|
||||
}
|
||||
|
||||
func defaultChainSelector() selector.Selector[chain.SelectableChainer] {
|
||||
return xs.NewSelector(xs.RoundRobinStrategy[chain.SelectableChainer]())
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
tls_util "github.com/go-gost/x/internal/util/tls"
|
||||
"github.com/go-gost/x/metadata"
|
||||
"github.com/go-gost/x/registry"
|
||||
xs "github.com/go-gost/x/selector"
|
||||
)
|
||||
|
||||
func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
|
||||
@ -188,7 +187,7 @@ func parseForwarder(cfg *config.ForwarderConfig) *chain.NodeGroup {
|
||||
|
||||
sel := parseNodeSelector(cfg.Selector)
|
||||
if sel == nil {
|
||||
sel = xs.DefaultNodeSelector
|
||||
sel = defaultNodeSelector()
|
||||
}
|
||||
return group.WithSelector(sel)
|
||||
}
|
||||
@ -250,7 +249,7 @@ func chainGroup(name string, group *config.ChainGroupConfig) chain.Chainer {
|
||||
}
|
||||
|
||||
if sel == nil {
|
||||
sel = xs.DefaultChainSelector
|
||||
sel = defaultChainSelector()
|
||||
}
|
||||
|
||||
return chain.NewChainGroup(chains...).
|
||||
|
Reference in New Issue
Block a user