code: func (s *StanServer) subsSentAndAckReplicator() {
  	defer s.wg.Done()
  
  	s.mu.Lock()
  	sr := s.ssarepl
  	ready := sr.ready
  	waiting := sr.waiting
  	notifyCh := sr.notifyCh
  	s.mu.Unlock()
  
  	ticker := time.NewTicker(lazyReplicationInterval)
  
  	flush := func() {
  		ready.Range(func(k, _ interface{}) bool {
  			ready.Delete(k)
  			s.replicateSubSentAndAck(k.(*subState))
  			return true
  		})
  	}
  
  	for {
  		select {
  		case <-s.shutdownCh:
  			return
  		case <-ticker.C:
  			addedToReady := false
  			waiting.Range(func(k, _ interface{}) bool {
  				waiting.Delete(k)
  				// Move to ready map
  				ready.Store(k, struct{}{})
  				addedToReady = true
  				return true
  			})
  			// If some were transferred and nobody has signaled
  			// to flush the ready ones, do it here
  			if addedToReady && len(notifyCh) == 0 {
  				flush()
  			}
  		case <-notifyCh:
  			flush()
  		}
  	}
  }
docs: // long-lived go-routine that performs RAFT replication of subscriptions'
  // sent/ack operations.