func (c *cache) cp(current []*registry.Service) []*registry.Service {
	var services []*registry.Service
	for _, service := range current {
		s := new(registry.Service)
		*s = *service
		var nodes []*registry.Node
		for _, node := range service.Nodes {
			n := new(registry.Node)
			*n = *node
			nodes = append(nodes, n)
		}
		s.Nodes = nodes
		var eps []*registry.Endpoint
		for _, ep := range service.Endpoints {
			e := new(registry.Endpoint)
			*e = *ep
			eps = append(eps, e)
		}
		s.Endpoints = eps
		services = append(services, s)
	}
	return services
}
cp copies a service. Because we're caching handing back pointers would
create a race condition, so we do this instead its fast enough
package rcache
import (
	"math"
	"math/rand"
	"sync"
	"time"
	log "github.com/micro/go-log"
	"github.com/micro/go-micro/registry"
)
type Cache interface {
	registry.Registry
	Stop()
}
type Options struct {
	TTL time.Duration
}
type Option func(o *Options)
type cache struct {
	registry.Registry
	opts Options
	sync.RWMutex
	cache   map[string][]*registry.Service
	ttls    map[string]time.Time
	watched map[string]bool
	exit chan bool
}
var (
	DefaultTTL = time.Minute
)
func backoff(attempts int) time.Duration {
	if attempts == 0 {
		return time.Duration(0)
	}
	return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond
}
func (c *cache) isValid(services []*registry.Service, ttl time.Time) bool {
	if len(services) == 0 {
		return false
	}
	if ttl.IsZero() {
		return false
	}
	if time.Since(ttl) > c.opts.TTL {
		return false
	}
	return true
}
func (c *cache) quit() bool {
	select {
	case <-c.exit:
		return true
	default:
		return false
	}
}