code: func sendToLibhoney(ctx context.Context, toBeSent chan event.Event, toBeResent chan event.Event,
  	delaySending chan int, doneSending chan bool) {
  	for {
  		// check and see if we need to back off the API because of rate limiting
  		select {
  		case delay := <-delaySending:
  			time.Sleep(time.Duration(delay) * time.Millisecond)
  		default:
  		}
  		// if we have events to retransmit, send those first
  		select {
  		case ev := <-toBeResent:
  			// retransmitted events have already been sampled; always use
  			// SendPresampled() for these
  			sendEvent(ev)
  			continue
  		default:
  		}
  		// otherwise pick something up off the regular queue and send it
  		select {
  		case ev, ok := <-toBeSent:
  			if !ok {
  				// channel is closed
  				// NOTE: any unrtransmitted retransmittable events will be dropped
  				doneSending <- true
  				return
  			}
  			sendEvent(ev)
  			continue
  		default:
  		}
  		// no events at all? chill for a sec until we get the next one
  		time.Sleep(100 * time.Millisecond)
  	}
  }
docs: // sendToLibhoney reads from the toBeSent channel and shoves the events into
  // libhoney events, sending them on their way.