code: func (c *folderSummaryService) calculateSummaries() {
  	const pumpInterval = 2 * time.Second
  	pump := time.NewTimer(pumpInterval)
  
  	for {
  		select {
  		case <-pump.C:
  			t0 := time.Now()
  			for _, folder := range c.foldersToHandle() {
  				c.sendSummary(folder)
  			}
  
  			// We don't want to spend all our time calculating summaries. Lets
  			// set an arbitrary limit at not spending more than about 30% of
  			// our time here...
  			wait := 2*time.Since(t0) + pumpInterval
  			pump.Reset(wait)
  
  		case folder := <-c.immediate:
  			c.sendSummary(folder)
  
  		case <-c.stop:
  			return
  		}
  	}
  }
docs: // calculateSummaries periodically recalculates folder summaries and
  // completion percentage, and sends the results on the event bus.