2019-05-31 02:22:43 +03:00
|
|
|
// Package cache provides a registry cache
|
|
|
|
package cache
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
"math/rand"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
2020-07-27 15:22:00 +03:00
|
|
|
"github.com/micro/go-micro/v3/logger"
|
|
|
|
"github.com/micro/go-micro/v3/registry"
|
|
|
|
util "github.com/micro/go-micro/v3/util/registry"
|
2019-05-31 02:22:43 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Cache is the registry cache interface
|
|
|
|
type Cache interface {
|
|
|
|
// embed the registry interface
|
|
|
|
registry.Registry
|
|
|
|
// stop the cache watcher
|
|
|
|
Stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
type Options struct {
|
|
|
|
// TTL is the cache TTL
|
|
|
|
TTL time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(o *Options)
|
|
|
|
|
|
|
|
type cache struct {
|
|
|
|
registry.Registry
|
|
|
|
opts Options
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// registry cache. services,ttls,watched,running are grouped by doman
|
2019-05-31 02:22:43 +03:00
|
|
|
sync.RWMutex
|
2020-06-19 15:16:44 +03:00
|
|
|
services map[string]services
|
|
|
|
ttls map[string]ttls
|
|
|
|
watched map[string]watched
|
|
|
|
running map[string]bool
|
2019-05-31 02:22:43 +03:00
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// used to stop the caches
|
2019-05-31 02:22:43 +03:00
|
|
|
exit chan bool
|
2019-09-25 21:44:46 +03:00
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// indicate whether its running status of the registry used to hold onto the cache in failure state
|
2019-09-25 21:44:46 +03:00
|
|
|
status error
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
type services map[string][]*registry.Service
|
|
|
|
type ttls map[string]time.Time
|
|
|
|
type watched map[string]bool
|
|
|
|
|
|
|
|
var defaultTTL = time.Minute
|
2019-05-31 02:22:43 +03:00
|
|
|
|
|
|
|
func backoff(attempts int) time.Duration {
|
|
|
|
if attempts == 0 {
|
|
|
|
return time.Duration(0)
|
|
|
|
}
|
|
|
|
return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond
|
|
|
|
}
|
|
|
|
|
2019-09-25 21:44:46 +03:00
|
|
|
func (c *cache) getStatus() error {
|
|
|
|
c.RLock()
|
|
|
|
defer c.RUnlock()
|
|
|
|
return c.status
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cache) setStatus(err error) {
|
|
|
|
c.Lock()
|
|
|
|
c.status = err
|
|
|
|
c.Unlock()
|
|
|
|
}
|
|
|
|
|
2019-05-31 02:22:43 +03:00
|
|
|
// isValid checks if the service is valid
|
|
|
|
func (c *cache) isValid(services []*registry.Service, ttl time.Time) bool {
|
|
|
|
// no services exist
|
|
|
|
if len(services) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// ttl is invalid
|
|
|
|
if ttl.IsZero() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// time since ttl is longer than timeout
|
2019-10-30 09:01:51 +03:00
|
|
|
if time.Since(ttl) > 0 {
|
2019-05-31 02:22:43 +03:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// ok
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cache) quit() bool {
|
|
|
|
select {
|
|
|
|
case <-c.exit:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
func (c *cache) del(domain, service string) {
|
2019-09-25 21:44:46 +03:00
|
|
|
// don't blow away cache in error state
|
2020-06-19 15:16:44 +03:00
|
|
|
if err := c.getStatus(); err != nil {
|
2019-09-25 21:44:46 +03:00
|
|
|
return
|
|
|
|
}
|
2020-06-19 15:16:44 +03:00
|
|
|
|
|
|
|
c.Lock()
|
|
|
|
defer c.Unlock()
|
|
|
|
|
|
|
|
if _, ok := c.services[domain]; ok {
|
|
|
|
delete(c.services[domain], service)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := c.ttls[domain]; ok {
|
|
|
|
delete(c.ttls[domain], service)
|
|
|
|
}
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
func (c *cache) get(domain, service string) ([]*registry.Service, error) {
|
|
|
|
var services []*registry.Service
|
|
|
|
var ttl time.Time
|
2019-05-31 02:22:43 +03:00
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// lookup the values in the cache before calling the underlying registrry
|
|
|
|
c.RLock()
|
|
|
|
if srvs, ok := c.services[domain]; ok {
|
|
|
|
services = srvs[service]
|
|
|
|
}
|
|
|
|
if tt, ok := c.ttls[domain]; ok {
|
|
|
|
ttl = tt[service]
|
|
|
|
}
|
|
|
|
c.RUnlock()
|
2019-10-04 18:29:56 +03:00
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// got services && within ttl so return a copy of the services
|
|
|
|
if c.isValid(services, ttl) {
|
|
|
|
return util.Copy(services), nil
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// get does the actual request for a service and cache it
|
2020-06-19 15:16:44 +03:00
|
|
|
get := func(domain string, service string, cached []*registry.Service) ([]*registry.Service, error) {
|
2019-05-31 02:22:43 +03:00
|
|
|
// ask the registry
|
2020-06-19 15:16:44 +03:00
|
|
|
services, err := c.Registry.GetService(service, registry.GetDomain(domain))
|
2019-05-31 02:22:43 +03:00
|
|
|
if err != nil {
|
2020-06-19 15:16:44 +03:00
|
|
|
// set the error status
|
|
|
|
c.setStatus(err)
|
|
|
|
|
2019-09-25 21:44:46 +03:00
|
|
|
// check the cache
|
|
|
|
if len(cached) > 0 {
|
2019-10-04 18:29:56 +03:00
|
|
|
return cached, nil
|
2019-09-25 21:44:46 +03:00
|
|
|
}
|
2020-06-19 15:16:44 +03:00
|
|
|
|
2019-09-25 21:44:46 +03:00
|
|
|
// otherwise return error
|
2019-05-31 02:22:43 +03:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-09-25 21:44:46 +03:00
|
|
|
// reset the status
|
2019-10-11 12:47:42 +03:00
|
|
|
if err := c.getStatus(); err != nil {
|
2019-09-25 21:44:46 +03:00
|
|
|
c.setStatus(nil)
|
|
|
|
}
|
|
|
|
|
2019-05-31 02:22:43 +03:00
|
|
|
// cache results
|
2020-06-19 15:16:44 +03:00
|
|
|
c.set(domain, service, util.Copy(services))
|
2019-05-31 02:22:43 +03:00
|
|
|
|
|
|
|
return services, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// watch service if not watched
|
2020-06-19 15:16:44 +03:00
|
|
|
c.RLock()
|
|
|
|
var ok bool
|
|
|
|
if _, d := c.watched[domain]; d {
|
|
|
|
if _, s := c.watched[domain][service]; s {
|
|
|
|
ok = true
|
|
|
|
}
|
|
|
|
}
|
2019-10-04 18:40:21 +03:00
|
|
|
c.RUnlock()
|
|
|
|
|
2019-11-06 18:49:40 +03:00
|
|
|
// check if its being watched
|
|
|
|
if !ok {
|
|
|
|
c.Lock()
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// add domain if not registered
|
|
|
|
if _, ok := c.watched[domain]; !ok {
|
|
|
|
c.watched[domain] = make(map[string]bool)
|
|
|
|
}
|
|
|
|
|
2019-11-06 18:49:40 +03:00
|
|
|
// set to watched
|
2020-06-19 15:16:44 +03:00
|
|
|
c.watched[domain][service] = true
|
|
|
|
|
|
|
|
running := c.running[domain]
|
|
|
|
c.Unlock()
|
2019-11-06 18:49:40 +03:00
|
|
|
|
|
|
|
// only kick it off if not running
|
2020-06-19 15:16:44 +03:00
|
|
|
if !running {
|
|
|
|
go c.run(domain)
|
2019-11-06 18:49:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-31 02:22:43 +03:00
|
|
|
// get and return services
|
2020-06-19 15:16:44 +03:00
|
|
|
return get(domain, service, services)
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
func (c *cache) set(domain string, service string, srvs []*registry.Service) {
|
|
|
|
c.Lock()
|
|
|
|
defer c.Unlock()
|
|
|
|
|
|
|
|
if _, ok := c.services[domain]; !ok {
|
|
|
|
c.services[domain] = make(services)
|
|
|
|
}
|
|
|
|
if _, ok := c.ttls[domain]; !ok {
|
|
|
|
c.ttls[domain] = make(ttls)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.services[domain][service] = srvs
|
|
|
|
c.ttls[domain][service] = time.Now().Add(c.opts.TTL)
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
func (c *cache) update(domain string, res *registry.Result) {
|
2019-05-31 02:22:43 +03:00
|
|
|
if res == nil || res.Service == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// only save watched services since the service using the cache may only depend on a handful
|
|
|
|
// of other services
|
|
|
|
c.RLock()
|
2019-11-06 18:49:40 +03:00
|
|
|
if _, ok := c.watched[res.Service.Name]; !ok {
|
2020-06-19 15:16:44 +03:00
|
|
|
c.RUnlock()
|
2019-11-06 18:49:40 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// we're not going to cache anything unless there was already a lookup
|
|
|
|
services, ok := c.services[domain][res.Service.Name]
|
2019-05-31 02:22:43 +03:00
|
|
|
if !ok {
|
2020-06-19 15:16:44 +03:00
|
|
|
c.RUnlock()
|
2019-05-31 02:22:43 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
c.RUnlock()
|
|
|
|
|
2019-05-31 02:22:43 +03:00
|
|
|
if len(res.Service.Nodes) == 0 {
|
|
|
|
switch res.Action {
|
|
|
|
case "delete":
|
2020-06-19 15:16:44 +03:00
|
|
|
c.del(domain, res.Service.Name)
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// existing service found
|
|
|
|
var service *registry.Service
|
|
|
|
var index int
|
|
|
|
for i, s := range services {
|
|
|
|
if s.Version == res.Service.Version {
|
|
|
|
service = s
|
|
|
|
index = i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch res.Action {
|
|
|
|
case "create", "update":
|
|
|
|
if service == nil {
|
2020-06-19 15:16:44 +03:00
|
|
|
c.set(domain, res.Service.Name, append(services, res.Service))
|
2019-05-31 02:22:43 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// append old nodes to new service
|
|
|
|
for _, cur := range service.Nodes {
|
|
|
|
var seen bool
|
|
|
|
for _, node := range res.Service.Nodes {
|
|
|
|
if cur.Id == node.Id {
|
|
|
|
seen = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !seen {
|
|
|
|
res.Service.Nodes = append(res.Service.Nodes, cur)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
services[index] = res.Service
|
2020-06-19 15:16:44 +03:00
|
|
|
c.set(domain, res.Service.Name, services)
|
2019-05-31 02:22:43 +03:00
|
|
|
case "delete":
|
|
|
|
if service == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var nodes []*registry.Node
|
|
|
|
|
|
|
|
// filter cur nodes to remove the dead one
|
|
|
|
for _, cur := range service.Nodes {
|
|
|
|
var seen bool
|
|
|
|
for _, del := range res.Service.Nodes {
|
|
|
|
if del.Id == cur.Id {
|
|
|
|
seen = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !seen {
|
|
|
|
nodes = append(nodes, cur)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// still got nodes, save and return
|
|
|
|
if len(nodes) > 0 {
|
|
|
|
service.Nodes = nodes
|
|
|
|
services[index] = service
|
2020-06-19 15:16:44 +03:00
|
|
|
c.set(domain, service.Name, services)
|
2019-05-31 02:22:43 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// zero nodes left
|
|
|
|
|
|
|
|
// only have one thing to delete
|
|
|
|
// nuke the thing
|
|
|
|
if len(services) == 1 {
|
2020-06-19 15:16:44 +03:00
|
|
|
c.del(domain, service.Name)
|
2019-05-31 02:22:43 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// still have more than 1 service
|
|
|
|
// check the version and keep what we know
|
|
|
|
var srvs []*registry.Service
|
|
|
|
for _, s := range services {
|
|
|
|
if s.Version != service.Version {
|
|
|
|
srvs = append(srvs, s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// save
|
2020-06-19 15:16:44 +03:00
|
|
|
c.set(domain, service.Name, srvs)
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// run starts the cache watcher loop
|
|
|
|
// it creates a new watcher if there's a problem
|
2020-06-19 15:16:44 +03:00
|
|
|
func (c *cache) run(domain string) {
|
2019-05-31 02:22:43 +03:00
|
|
|
c.Lock()
|
2020-06-19 15:16:44 +03:00
|
|
|
c.running[domain] = true
|
2019-05-31 02:22:43 +03:00
|
|
|
c.Unlock()
|
|
|
|
|
2019-11-06 18:49:40 +03:00
|
|
|
// reset watcher on exit
|
2019-05-31 02:22:43 +03:00
|
|
|
defer func() {
|
|
|
|
c.Lock()
|
2020-06-19 15:16:44 +03:00
|
|
|
c.watched[domain] = make(map[string]bool)
|
|
|
|
c.running[domain] = false
|
2019-05-31 02:22:43 +03:00
|
|
|
c.Unlock()
|
|
|
|
}()
|
|
|
|
|
|
|
|
var a, b int
|
|
|
|
|
|
|
|
for {
|
|
|
|
// exit early if already dead
|
|
|
|
if c.quit() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// jitter before starting
|
|
|
|
j := rand.Int63n(100)
|
|
|
|
time.Sleep(time.Duration(j) * time.Millisecond)
|
|
|
|
|
|
|
|
// create new watcher
|
2020-06-19 15:16:44 +03:00
|
|
|
w, err := c.Registry.Watch(registry.WatchDomain(domain))
|
2019-05-31 02:22:43 +03:00
|
|
|
if err != nil {
|
|
|
|
if c.quit() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
d := backoff(a)
|
2019-09-25 21:44:46 +03:00
|
|
|
c.setStatus(err)
|
2019-05-31 02:22:43 +03:00
|
|
|
|
|
|
|
if a > 3 {
|
2020-04-08 12:50:19 +03:00
|
|
|
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
|
|
|
|
logger.Debug("rcache: ", err, " backing off ", d)
|
2020-03-11 20:55:39 +03:00
|
|
|
}
|
2019-05-31 02:22:43 +03:00
|
|
|
a = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(d)
|
|
|
|
a++
|
|
|
|
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset a
|
|
|
|
a = 0
|
|
|
|
|
|
|
|
// watch for events
|
2020-06-19 15:16:44 +03:00
|
|
|
if err := c.watch(domain, w); err != nil {
|
2019-05-31 02:22:43 +03:00
|
|
|
if c.quit() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
d := backoff(b)
|
2019-09-25 21:44:46 +03:00
|
|
|
c.setStatus(err)
|
2019-05-31 02:22:43 +03:00
|
|
|
|
|
|
|
if b > 3 {
|
2020-04-08 12:50:19 +03:00
|
|
|
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
|
|
|
|
logger.Debug("rcache: ", err, " backing off ", d)
|
2020-03-11 20:55:39 +03:00
|
|
|
}
|
2019-05-31 02:22:43 +03:00
|
|
|
b = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(d)
|
|
|
|
b++
|
|
|
|
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset b
|
|
|
|
b = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// watch loops the next event and calls update
|
|
|
|
// it returns if there's an error
|
2020-06-19 15:16:44 +03:00
|
|
|
func (c *cache) watch(domain string, w registry.Watcher) error {
|
2019-08-02 01:03:11 +03:00
|
|
|
// used to stop the watch
|
|
|
|
stop := make(chan bool)
|
2019-05-31 02:22:43 +03:00
|
|
|
|
|
|
|
// manage this loop
|
|
|
|
go func() {
|
2019-08-02 01:03:11 +03:00
|
|
|
defer w.Stop()
|
|
|
|
|
|
|
|
select {
|
2019-05-31 02:22:43 +03:00
|
|
|
// wait for exit
|
2019-08-02 01:03:11 +03:00
|
|
|
case <-c.exit:
|
|
|
|
return
|
|
|
|
// we've been stopped
|
|
|
|
case <-stop:
|
|
|
|
return
|
|
|
|
}
|
2019-05-31 02:22:43 +03:00
|
|
|
}()
|
|
|
|
|
|
|
|
for {
|
|
|
|
res, err := w.Next()
|
|
|
|
if err != nil {
|
2019-08-02 01:03:11 +03:00
|
|
|
close(stop)
|
2019-05-31 02:22:43 +03:00
|
|
|
return err
|
|
|
|
}
|
2019-09-25 21:44:46 +03:00
|
|
|
|
|
|
|
// reset the error status since we succeeded
|
|
|
|
if err := c.getStatus(); err != nil {
|
|
|
|
// reset status
|
|
|
|
c.setStatus(nil)
|
|
|
|
}
|
|
|
|
|
2020-06-19 15:16:44 +03:00
|
|
|
// for wildcard queries, the domain will be * and not the services domain, so we'll check to
|
|
|
|
// see if it was provided in the metadata.
|
|
|
|
dom := domain
|
|
|
|
if res.Service.Metadata != nil && len(res.Service.Metadata["domain"]) > 0 {
|
|
|
|
dom = res.Service.Metadata["domain"]
|
|
|
|
}
|
|
|
|
|
|
|
|
c.update(dom, res)
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-14 14:32:59 +03:00
|
|
|
func (c *cache) GetService(service string, opts ...registry.GetOption) ([]*registry.Service, error) {
|
2020-06-19 15:16:44 +03:00
|
|
|
// parse the options, fallback to the default domain
|
|
|
|
var options registry.GetOptions
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
|
|
|
if len(options.Domain) == 0 {
|
|
|
|
options.Domain = registry.DefaultDomain
|
|
|
|
}
|
|
|
|
|
2019-05-31 02:22:43 +03:00
|
|
|
// get the service
|
2020-06-19 15:16:44 +03:00
|
|
|
services, err := c.get(options.Domain, service)
|
2019-05-31 02:22:43 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// if there's nothing return err
|
|
|
|
if len(services) == 0 {
|
|
|
|
return nil, registry.ErrNotFound
|
|
|
|
}
|
|
|
|
|
|
|
|
// return services
|
|
|
|
return services, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cache) Stop() {
|
2019-11-06 18:49:40 +03:00
|
|
|
c.Lock()
|
|
|
|
defer c.Unlock()
|
|
|
|
|
2019-05-31 02:22:43 +03:00
|
|
|
select {
|
|
|
|
case <-c.exit:
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
close(c.exit)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cache) String() string {
|
2019-10-15 00:39:26 +03:00
|
|
|
return "cache"
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new cache
|
|
|
|
func New(r registry.Registry, opts ...Option) Cache {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
options := Options{
|
2020-06-19 15:16:44 +03:00
|
|
|
TTL: defaultTTL,
|
2019-05-31 02:22:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &cache{
|
|
|
|
Registry: r,
|
|
|
|
opts: options,
|
2020-06-19 15:16:44 +03:00
|
|
|
running: make(map[string]bool),
|
|
|
|
watched: make(map[string]watched),
|
|
|
|
services: make(map[string]services),
|
|
|
|
ttls: make(map[string]ttls),
|
2019-05-31 02:22:43 +03:00
|
|
|
exit: make(chan bool),
|
|
|
|
}
|
|
|
|
}
|