code: func (b *batchProducer) Flush(timeout time.Duration, sendStats bool) (int, int, error) {
  	b.Stop()
  
  	timer := time.NewTimer(timeout)
  	if timeout == 0 {
  		timer.Stop()
  	}
  
  	timedOut := false
  	sent := 0
  
  loop:
  	for len(b.records) > 0 {
  		select {
  		case <-timer.C:
  			timedOut = true
  			break loop
  		default:
  			sent += b.sendBatch(MaxKinesisBatchSize)
  		}
  	}
  
  	if !timedOut && sendStats {
  		b.sendStats()
  	}
  
  	return sent, len(b.records), nil
  }
docs: // from/for interface Producer
  // TODO: send all batches in parallel, will require broader refactoring