New returns a new cache.
(r registry.Registry, opts ...Option)
| 560 | |
| 561 | // New returns a new cache. |
| 562 | func New(r registry.Registry, opts ...Option) Cache { |
| 563 | |
| 564 | options := Options{ |
| 565 | TTL: DefaultTTL, |
| 566 | MinimumRetryInterval: DefaultMinimumRetryInterval, |
| 567 | Logger: log.DefaultLogger, |
| 568 | } |
| 569 | |
| 570 | for _, o := range opts { |
| 571 | o(&options) |
| 572 | } |
| 573 | |
| 574 | return &cache{ |
| 575 | Registry: r, |
| 576 | opts: options, |
| 577 | watched: make(map[string]bool), |
| 578 | watchedRunning: make(map[string]bool), |
| 579 | cache: make(map[string][]*registry.Service), |
| 580 | ttls: make(map[string]time.Time), |
| 581 | nttls: make(map[string]map[string]time.Time), |
| 582 | lastRefreshAttempt: make(map[string]time.Time), |
| 583 | exit: make(chan bool), |
| 584 | } |
| 585 | } |
no outgoing calls