code: func newBatchingEmitter(iterations, burstSize int, latency time.Duration, cb emitBatchCallback) batchingEmitter {
  	if iterations < 0 {
  		panic(errors.Errorf("Got a negative iterations number"))
  	}
  
  	p := &batchingEmitterImpl{
  		cb:         cb,
  		delay:      latency,
  		iterations: iterations,
  		burstSize:  burstSize,
  		lock:       &sync.Mutex{},
  		buff:       make([]*batchedMessage, 0),
  		stopFlag:   int32(0),
  	}
  
  	if iterations != 0 {
  		go p.periodicEmit()
  	}
  
  	return p
  }
docs: // newBatchingEmitter accepts the following parameters:
  // iterations: number of times each message is forwarded
  // burstSize: a threshold that triggers a forwarding because of message count
  // latency: the maximum delay that each message can be stored without being forwarded
  // cb: a callback that is called in order for the forwarding to take place