mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
strategy: try fwrdrs 1 by 1 when len(avail)==0
This commit is contained in:
parent
c4cebdd1d8
commit
fda05d5d3d
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/nadoo/glider
|
||||
|
||||
go 1.13
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/klauspost/cpuid v1.2.3 // indirect
|
||||
|
@ -98,7 +98,6 @@ func parseRequest(r *bufio.Reader) (*request, error) {
|
||||
req.ruri = u.String()
|
||||
} else {
|
||||
req.ruri = u.String()
|
||||
|
||||
base, err := url.Parse("http://" + header.Get("Host"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -126,7 +126,7 @@ func (p *Proxy) NextForwarder(dstAddr string) *Forwarder {
|
||||
defer p.mu.RUnlock()
|
||||
|
||||
if len(p.avail) == 0 {
|
||||
return p.fwdrs[0]
|
||||
return p.fwdrs[atomic.AddUint32(&p.index, 1)%uint32(len(p.fwdrs))]
|
||||
}
|
||||
|
||||
return p.next(dstAddr)
|
||||
@ -157,7 +157,7 @@ func (p *Proxy) init() {
|
||||
if len(p.avail) == 0 {
|
||||
// no available forwarders, set priority to 0 to check all forwarders in check func
|
||||
p.SetPriority(0)
|
||||
log.F("[strategy] no available forwarders, please check your config file or network settings", p.fwdrs[0].Addr())
|
||||
log.F("[strategy] no available forwarders, please check your config file or network settings")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user