code: func (s *SQLStore) subStoresFlusher() {
  	defer s.wg.Done()
  
  	s.Lock()
  	flusher := s.ssFlusher
  	s.Unlock()
  
  	var (
  		stores []*SQLSubStore
  		tm     = time.NewTimer(sqlSubStoreFlushIdleInterval)
  	)
  
  	for {
  		select {
  		case <-s.doneCh:
  			return
  		case <-flusher.signalCh:
  			if !tm.Stop() {
  				<-tm.C
  			}
  			tm.Reset(sqlSubStoreFlushInterval)
  		case <-tm.C:
  			flusher.Lock()
  			for ss := range flusher.stores {
  				stores = append(stores, ss)
  				delete(flusher.stores, ss)
  			}
  			flusher.signaled = false
  			flusher.Unlock()
  			for _, ss := range stores {
  				ss.Flush()
  			}
  			stores = stores[:0]
  			tm.Reset(sqlSubStoreFlushIdleInterval)
  		}
  	}
  }
docs: // When a SubStore adds a pending message or an ack, it will
  // notify this go-routine so that the store gets flushed after
  // some time should it not be flushed explicitly.
  // This go routine waits to be signaled and when that happens
  // reset a timer to fire in a short period of time. It then
  // go through the list of SubStore that have been registered
  // as needing a flush and call Flush() on them.