diff --git a/middleware/proxy/policy.go b/middleware/proxy/policy.go index 27e02a17..a2522bcb 100644 --- a/middleware/proxy/policy.go +++ b/middleware/proxy/policy.go @@ -13,6 +13,12 @@ type Policy interface { Select(pool HostPool) *UpstreamHost } +func init() { + RegisterPolicy("random", func() Policy { return &Random{} }) + RegisterPolicy("least_conn", func() Policy { return &LeastConn{} }) + RegisterPolicy("round_robin", func() Policy { return &RoundRobin{} }) +} + // Random is a policy that selects up hosts from a pool at random. type Random struct{} diff --git a/middleware/proxy/upstream.go b/middleware/proxy/upstream.go index 03bba0e6..a657a088 100644 --- a/middleware/proxy/upstream.go +++ b/middleware/proxy/upstream.go @@ -27,12 +27,6 @@ type staticUpstream struct { } } -func init() { - RegisterPolicy("random", func() Policy { return &Random{} }) - RegisterPolicy("least_conn", func() Policy { return &LeastConn{} }) - RegisterPolicy("round_robin", func() Policy { return &RoundRobin{} }) -} - // NewStaticUpstreams parses the configuration input and sets up // static upstreams for the proxy middleware. func NewStaticUpstreams(c parse.Dispenser) ([]Upstream, error) {