mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
adding sequential policy to forward plugin (#1704)
* adding sequential policy to forward plugin * making sequential an alias to first in proxy plugin
This commit is contained in:
committed by
Miek Gieben
parent
26d1432ae6
commit
19a1ef48f2
@@ -47,7 +47,7 @@ forward FROM TO... {
|
||||
max_fails INTEGER
|
||||
tls CERT KEY CA
|
||||
tls_servername NAME
|
||||
policy random|round_robin
|
||||
policy random|round_robin|sequential
|
||||
health_check DURATION
|
||||
}
|
||||
~~~
|
||||
|
||||
@@ -193,6 +193,7 @@ type policy int
|
||||
const (
|
||||
randomPolicy policy = iota
|
||||
roundRobinPolicy
|
||||
sequentialPolicy
|
||||
)
|
||||
|
||||
const defaultTimeout = 5 * time.Second
|
||||
|
||||
@@ -53,3 +53,13 @@ func (r *roundRobin) List(p []*Proxy) []*Proxy {
|
||||
|
||||
return robin
|
||||
}
|
||||
|
||||
// sequential is a policy that selects hosts based on sequential ordering.
|
||||
type sequential struct {}
|
||||
|
||||
func (r *sequential) String() string { return "sequential" }
|
||||
|
||||
func (r *sequential) List(p []*Proxy) []*Proxy {
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,8 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
|
||||
f.p = &random{}
|
||||
case "round_robin":
|
||||
f.p = &roundRobin{}
|
||||
case "sequential":
|
||||
f.p = &sequential{}
|
||||
default:
|
||||
return c.Errf("unknown policy '%s'", x)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ func TestSetupPolicy(t *testing.T) {
|
||||
// positive
|
||||
{"forward . 127.0.0.1 {\npolicy random\n}\n", false, "random", ""},
|
||||
{"forward . 127.0.0.1 {\npolicy round_robin\n}\n", false, "round_robin", ""},
|
||||
{"forward . 127.0.0.1 {\npolicy sequential\n}\n", false, "sequential", ""},
|
||||
// negative
|
||||
{"forward . 127.0.0.1 {\npolicy random2\n}\n", true, "random", "unknown policy"},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user