code: func (hec *Client) WaitForAcknowledgementWithContext(ctx context.Context) error {
  	// Make our own copy of the list of acknowledgement IDs and remove them
  	// from the client while we check them.
  	hec.ackMux.Lock()
  	ackIDs := hec.ackIDs
  	hec.ackIDs = nil
  	hec.ackMux.Unlock()
  
  	if len(ackIDs) == 0 {
  		return nil
  	}
  
  	endpoint := "/services/collector/ack?channel=" + hec.channel
  
  	for {
  		ackRequestData, _ := json.Marshal(acknowledgementRequest{Acks: ackIDs})
  
  		response, err := hec.makeRequest(ctx, endpoint, ackRequestData)
  		if err != nil {
  			// Put the remaining unacknowledged IDs back
  			hec.ackMux.Lock()
  			hec.ackIDs = append(hec.ackIDs, ackIDs...)
  			hec.ackMux.Unlock()
  			return err
  		}
  
  		for ackIDString, status := range response.Acks {
  			if status {
  				ackID, err := strconv.Atoi(ackIDString)
  				if err != nil {
  					return fmt.Errorf("could not convert ack ID to int: %v", err)
  				}
  
  				ackIDs = remove(ackIDs, ackID)
  			}
  		}
  
  		if len(ackIDs) == 0 {
  			break
  		}
  
  		// If the server did not indicate that all acknowledgements have been
  		// made, check again after a short delay.
  		select {
  		case <-time.After(retryWaitTime):
  			continue
  		case <-ctx.Done():
  			// Put the remaining unacknowledged IDs back
  			hec.ackMux.Lock()
  			hec.ackIDs = append(hec.ackIDs, ackIDs...)
  			hec.ackMux.Unlock()
  			return ctx.Err()
  		}
  	}
  
  	return nil
  }
docs: // WaitForAcknowledgementWithContext blocks until the Splunk indexer has
  // acknowledged that all previously submitted data has been successfully
  // indexed or if the provided context is cancelled. This requires the HEC token
  // configuration in Splunk to have indexer acknowledgement enabled.