mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 10:43:20 -05:00 
			
		
		
		
	more
This commit is contained in:
		@@ -11,6 +11,11 @@ import (
 | 
			
		||||
	etcdc "github.com/coreos/etcd/client"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	priority = 10   // default priority when nothing is set
 | 
			
		||||
	ttl      = 3600 // default ttl when nothing is set
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (g *Backend) Records(name string, exact bool) ([]msg.Service, error) {
 | 
			
		||||
	path, star := msg.PathWithWildcard(name)
 | 
			
		||||
	r, err := g.get(path, true)
 | 
			
		||||
@@ -125,7 +130,7 @@ Nodes:
 | 
			
		||||
		serv.Key = n.Key
 | 
			
		||||
		serv.Ttl = g.calculateTtl(n, serv)
 | 
			
		||||
		if serv.Priority == 0 {
 | 
			
		||||
			serv.Priority = int(g.config.Priority)
 | 
			
		||||
			serv.Priority = priority
 | 
			
		||||
		}
 | 
			
		||||
		sx = append(sx, *serv)
 | 
			
		||||
	}
 | 
			
		||||
@@ -139,7 +144,7 @@ func (g *Backend) calculateTtl(node *etcdc.Node, serv *msg.Service) uint32 {
 | 
			
		||||
	etcdTtl := uint32(node.TTL)
 | 
			
		||||
 | 
			
		||||
	if etcdTtl == 0 && serv.Ttl == 0 {
 | 
			
		||||
		return g.config.Ttl
 | 
			
		||||
		return ttl
 | 
			
		||||
	}
 | 
			
		||||
	if etcdTtl == 0 {
 | 
			
		||||
		return serv.Ttl
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@
 | 
			
		||||
package etcd
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/miekg/coredns/middleware"
 | 
			
		||||
	"github.com/skynetservices/skydns/singleflight"
 | 
			
		||||
 | 
			
		||||
	etcd "github.com/coreos/etcd/client"
 | 
			
		||||
@@ -10,25 +11,18 @@ import (
 | 
			
		||||
 | 
			
		||||
type (
 | 
			
		||||
	Etcd struct {
 | 
			
		||||
		Ttl      uint32
 | 
			
		||||
		Priority uint16
 | 
			
		||||
		Backend  *Backend
 | 
			
		||||
		Next middleware.Handler
 | 
			
		||||
 | 
			
		||||
		client   etcd.KeysAPI
 | 
			
		||||
		ctx      context.Context
 | 
			
		||||
		inflight *singleflight.Group
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Backend struct {
 | 
			
		||||
	client   etcd.KeysAPI
 | 
			
		||||
	ctx      context.Context
 | 
			
		||||
	config   *Config
 | 
			
		||||
	inflight *singleflight.Group
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewBackend returns a new Backend.
 | 
			
		||||
func NewBackend(client etcd.KeysAPI, ctx context.Context, config *Config) *Backend {
 | 
			
		||||
	return &Backend{
 | 
			
		||||
func NewEtcd(client etcd.KeysAPI, ctx context.Context) Etcd {
 | 
			
		||||
	return Etcd{
 | 
			
		||||
		client:   client,
 | 
			
		||||
		ctx:      ctx,
 | 
			
		||||
		config:   config,
 | 
			
		||||
		inflight: &singleflight.Group{},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user