mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 10:43:20 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			660 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			660 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Package loadbalance is plugin for rewriting responses to do "load balancing"
 | 
						|
package loadbalance
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
 | 
						|
	"github.com/coredns/coredns/plugin"
 | 
						|
 | 
						|
	"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" }
 |