code: func (cc *CachingConnector) Close() {
  	cc.lock.RLock()
  	// Safety check to see if the connector has been closed. This represents a
  	// bug in the calling code, but it's not good to panic here.
  	if cc.janitorDone == nil {
  		cc.lock.RUnlock()
  		logger.Warn("Trying to close connector after already closed")
  		return
  	}
  	cc.lock.RUnlock()
  	logger.Debug("closing caching GRPC connector")
  
  	select {
  	case <-cc.janitorClosed:
  		logger.Debug("janitor not running")
  	default:
  		logger.Debug("janitor running")
  		cc.janitorDone <- true
  		cc.waitgroup.Wait()
  	}
  
  	cc.lock.Lock()
  	defer cc.lock.Unlock()
  
  	if len(cc.index) > 0 {
  		logger.Debugf("flushing connection cache with open connections [%d]", len(cc.index))
  	} else {
  		logger.Debug("flushing connection cache")
  	}
  
  	cc.flush()
  	close(cc.janitorClosed)
  	close(cc.janitorDone)
  	cc.janitorDone = nil
  }
docs: // Close cleans up cached connections.