summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/selectionpolicies.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-09 21:44:58 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-09 21:44:58 -0600
commitb4f4fcd437c2f9816f9511217bde703679808679 (patch)
tree610a26ff132abd1451e6c5ce64ade84873d876ba /modules/caddyhttp/reverseproxy/selectionpolicies.go
parent50e62d06bcbc6b6486b382a22c633772443cfb6d (diff)
Migrate some selection policy tests over to v2
Diffstat (limited to 'modules/caddyhttp/reverseproxy/selectionpolicies.go')
-rw-r--r--modules/caddyhttp/reverseproxy/selectionpolicies.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go
index 9680583..5bb2d62 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
}