diff options
author | Matthew Holt <[email protected]> | 2019-09-09 21:44:58 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-09-09 21:44:58 -0600 |
commit | b4f4fcd437c2f9816f9511217bde703679808679 (patch) | |
tree | 610a26ff132abd1451e6c5ce64ade84873d876ba /modules/caddyhttp/reverseproxy/selectionpolicies.go | |
parent | 50e62d06bcbc6b6486b382a22c633772443cfb6d (diff) | |
download | caddy-b4f4fcd437c2f9816f9511217bde703679808679.tar.gz caddy-b4f4fcd437c2f9816f9511217bde703679808679.zip |
Migrate some selection policy tests over to v2
Diffstat (limited to 'modules/caddyhttp/reverseproxy/selectionpolicies.go')
-rw-r--r-- | modules/caddyhttp/reverseproxy/selectionpolicies.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go index 96805837d..5bb2d62dc 100644 --- a/modules/caddyhttp/reverseproxy/selectionpolicies.go +++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go @@ -82,7 +82,7 @@ type RandomChoiceSelection struct { // CaddyModule returns the Caddy module information. func (RandomChoiceSelection) CaddyModule() caddy.ModuleInfo { return caddy.ModuleInfo{ - Name: "http.handlers.reverse_proxy.selection_policies.random_choice", + Name: "http.handlers.reverse_proxy.selection_policies.random_choose", New: func() caddy.Module { return new(RandomChoiceSelection) }, } } @@ -147,14 +147,14 @@ func (LeastConnSelection) CaddyModule() caddy.ModuleInfo { func (LeastConnSelection) Select(pool UpstreamPool, _ *http.Request) *Upstream { var bestHost *Upstream var count int - var leastReqs int + leastReqs := -1 for _, host := range pool { if !host.Available() { continue } numReqs := host.NumRequests() - if numReqs < leastReqs { + if leastReqs == -1 || numReqs < leastReqs { leastReqs = numReqs count = 0 } |