code: func (s *Store) checkConnections() {
  	s.wg.Add(1)
  	ticker := time.NewTicker(s.connPollPeriod)
  	go func() {
  		defer s.wg.Done()
  		defer ticker.Stop()
  		for {
  			select {
  			case <-s.done:
  				return
  			case <-ticker.C:
  				// This is not a 100% correct check, but is right almost all
  				// the time, and saves the node from most unneeded network
  				// access. Read https://github.com/rqlite/rqlite/issues/5
  				if !s.IsLeader() {
  					continue
  				}
  
  				var conns []*Connection
  				s.connsMu.RLock()
  				for _, c := range s.conns {
  					// Sometimes IDs are in the slice without a connection, if a
  					// connection is in process of being formed via consensus.
  					if c == nil || c.ID == defaultConnID {
  						continue
  					}
  					if c.IdleTimedOut() || c.TxTimedOut() {
  						conns = append(conns, c)
  					}
  				}
  				s.connsMu.RUnlock()
  
  				for _, c := range conns {
  					if err := c.Close(); err != nil {
  						if err == ErrNotLeader {
  							// Not an issue, the actual leader will close it.
  							continue
  						}
  						s.logger.Printf("%s failed to close: %s", c, err.Error())
  					}
  					s.logger.Printf("%s closed due to timeout", c)
  					// Only increment stat here to make testing easier.
  					stats.Add(numConnTimeouts, 1)
  				}
  			}
  		}
  	}()
  }
docs: // checkConnections periodically checks which connections should
  // close due to timeouts.