func newMonitoredCache()

in monitored_cache.go [47:80]


func newMonitoredCache(
	ctx context.Context,
	cache connectionInfoCache,
	cn instance.ConnName,
	failoverPeriod time.Duration,
	resolver instance.ConnectionNameResolver,
	logger debug.ContextLogger) *monitoredCache {

	c := &monitoredCache{
		openConnsCount:      new(uint64),
		closedCh:            make(chan struct{}),
		cn:                  cn,
		resolver:            resolver,
		logger:              logger,
		connectionInfoCache: cache,
	}
	if cn.HasDomainName() {
		c.domainNameTicker = time.NewTicker(failoverPeriod)
		go func() {
			for {
				select {
				case <-c.domainNameTicker.C:
					c.purgeClosedConns()
					c.checkDomainName(ctx)
				case <-c.closedCh:
					return
				}
			}
		}()

	}

	return c
}