* global: move to context Move from golang.org/x/net/context to std lib's context. Change done with: for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done for i in **/*.go; do goimports -w $i; done * drop from dns.pb.go as well
24 lines
660 B
Go
24 lines
660 B
Go
// Package loadbalance is plugin for rewriting responses to do "load balancing"
|
|
package loadbalance
|
|
|
|
import (
|
|
"github.com/coredns/coredns/plugin"
|
|
|
|
"context"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
// RoundRobin is plugin to rewrite responses for "load balancing".
|
|
type RoundRobin struct {
|
|
Next plugin.Handler
|
|
}
|
|
|
|
// ServeDNS implements the plugin.Handler interface.
|
|
func (rr RoundRobin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
|
wrr := &RoundRobinResponseWriter{w}
|
|
return plugin.NextOrFailure(rr.Name(), rr.Next, ctx, wrr, r)
|
|
}
|
|
|
|
// Name implements the Handler interface.
|
|
func (rr RoundRobin) Name() string { return "loadbalance" }
|