Documentation
¶
Index ¶
- Variables
- func Close(c io.Closer)
- func PluginError(err error) error
- func SplitByByte(s string, c byte) (string, string)
- func Unused(arg0 interface{}, args ...interface{})
- type Dnsredir
- type HealthCheck
- type Nameitem
- type Namelist
- type Policy
- type Random
- type RoundRobin
- type Sequential
- type Spray
- type Transport
- type Upstream
- type UpstreamHost
- type UpstreamHostDownFunc
- type UpstreamHostPool
Constants ¶
This section is empty.
Variables ¶
var ( UnusedParam = Unused UnusedResult = Unused )
var SupportedPolicies = map[string]Policy{ "random": &Random{}, "round_robin": &RoundRobin{}, "sequential": &Sequential{}, "spray": &Spray{}, }
SupportedPolicies is the collection of policies registered
Functions ¶
func Close ¶
see: https://blevesearch.com/news/Deferred-Cleanup,-Checking-Errors,-and-Potential-Problems/
func PluginError ¶
func SplitByByte ¶
Return two strings delimited by the `c' If `c' not found in `s', `s' and an empty string will be returned
Types ¶
type Dnsredir ¶
func (*Dnsredir) OnShutdown ¶
type HealthCheck ¶
type HealthCheck struct {
// contains filtered or unexported fields
}
func (*HealthCheck) Select ¶
func (hc *HealthCheck) Select() *UpstreamHost
Select an upstream host based on the policy and the health check result Taken from proxy/healthcheck/healthcheck.go with modification
func (*HealthCheck) Start ¶
func (hc *HealthCheck) Start()
func (*HealthCheck) Stop ¶
func (hc *HealthCheck) Stop()
type Nameitem ¶
func NewNameitemsWithPaths ¶
type Policy ¶
type Policy interface {
// nil will be selected if all hosts are down
// NOTE: Spray policy will always return a nonnull host
Select(pool UpstreamHostPool) *UpstreamHost
}
Policy decides how a host will be selected from a pool. When all hosts are unhealthy, it is assumed the health checking failed. In this case each policy will *randomly* return a host from the pool
to prevent no traffic to go through at all.
type Random ¶
type Random struct{}
Random is a policy that selects up hosts from a pool at random.
func (*Random) Select ¶
func (r *Random) Select(pool UpstreamHostPool) *UpstreamHost
Select selects an up host at random from the specified pool.
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
RoundRobin is a policy that selects hosts based on round robin ordering.
func (*RoundRobin) Select ¶
func (r *RoundRobin) Select(pool UpstreamHostPool) *UpstreamHost
Select selects an up host from the pool using a round robin ordering scheme.
func (*RoundRobin) String ¶
func (r *RoundRobin) String() string
type Sequential ¶
type Sequential struct{}
Sequential is a policy that selects always the first healthy host in the list order.
func (*Sequential) Select ¶
func (s *Sequential) Select(pool UpstreamHostPool) *UpstreamHost
Select always the first that is not Down, nil if all hosts are down
func (*Sequential) String ¶
func (s *Sequential) String() string
type Spray ¶
type Spray struct{}
Spray is a policy that selects a host from a pool at random. This should be used as a last ditch attempt to get
a host when all hosts are reporting unhealthy.
func (*Spray) Select ¶
func (s *Spray) Select(pool UpstreamHostPool) *UpstreamHost
Select selects an up host at random from the specified pool.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport settings Inspired from coredns/plugin/forward/persistent.go addr isn't sealed into this struct since it's a high-level item
type Upstream ¶
type Upstream interface {
// Check if given domain name should be routed to this upstream zone
Match(name string) bool
// Select an upstream host to be routed to, nil if no available host
Select() *UpstreamHost
Start() error
Stop() error
}
Upstream manages a pool of proxy upstream hosts see: github.com/coredns/proxy#proxy.go
func NewReloadableUpstreams ¶
func NewReloadableUpstreams(c *caddy.Controller) ([]Upstream, error)
Parses Caddy config input and return a list of reloadable upstream for this plugin
type UpstreamHost ¶
type UpstreamHost struct {
// contains filtered or unexported fields
}
UpstreamHost represents a single upstream DNS server
func (*UpstreamHost) Check ¶
func (uh *UpstreamHost) Check() error
For health check we send to . IN NS +norec message to the upstream. Dial timeouts and empty replies are considered fails
basically anything else constitutes a healthy upstream.
func (*UpstreamHost) Dial ¶
func (uh *UpstreamHost) Dial(proto string) (*persistConn, bool, error)
see: upstream.go/transToProto() Return:
#0 Persistent connection #1 true if it's a cached connection #2 error(if any)
func (*UpstreamHost) Down ¶
func (uh *UpstreamHost) Down() bool
Down checks whether the upstream host is down or not Down will try to use uh.downFunc first, and will fallback
to some default criteria if necessary.
type UpstreamHostDownFunc ¶
type UpstreamHostDownFunc func(*UpstreamHost) bool
UpstreamHostDownFunc can be used to customize how Down behaves see: proxy/healthcheck/healthcheck.go
type UpstreamHostPool ¶
type UpstreamHostPool []*UpstreamHost
UpstreamHostPool is an array of upstream DNS servers