Added health-check method

This commit is contained in:
Andrey Meshkov
2018-11-05 21:19:01 +03:00
parent d6f560ecaf
commit a6022fc198
4 changed files with 152 additions and 18 deletions

View File

@@ -42,8 +42,8 @@ func (p *UpstreamPlugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *
var reply *dns.Msg
var backendErr error
// TODO: Change the way we call upstreams
for _, upstream := range p.Upstreams {
for i := range p.Upstreams {
upstream := p.Upstreams[i]
reply, backendErr = upstream.Exchange(ctx, r)
if backendErr == nil {
w.WriteMsg(reply)
@@ -67,4 +67,4 @@ func (p *UpstreamPlugin) finalizer() {
log.Printf("Error while closing the upstream: %s", err)
}
}
}
}