func (p *KinesisStreamProducer) flushRecords(msgs []*KinesisMessage, size int, twg *throttled.WaitGroup) {
	defer twg.Done()
	request := &kinesis.PutRecordsInput{
		StreamName: aws.String(msgs[0].Stream),
		Records:    make([]*kinesis.PutRecordsRequestEntry, size, size),
	}
	for i := 0; i < size; i++ {
		request.Records[i] = &kinesis.PutRecordsRequestEntry{
			Data:         msgs[i].Data,
			PartitionKey: aws.String(msgs[0].PartitionKey),
		}
	}
	out, err := p.client.PutRecords(request)
	log.WithField("size", size).Debug("KinesisStreamProducer: flushed records")
	if err != nil {
		for i := 0; i < size; i++ {
			p.handleError(msgs[i], err, "", "KinesisStreamProducer: PutRecords request failed")
		}
		return
	}
	for i, record := range out.Records {
		if record.ErrorCode != nil || record.ErrorMessage != nil {
			p.handleError(msgs[i], err, stringPtrToString(record.ErrorCode), stringPtrToString(record.ErrorMessage))
		} else if p.config.AckSuccess {
			p.successes <- msgs[i]
		}
	}
}
func (p *KinesisStreamProducer) flushSingleRecord(msg *KinesisMessage, twg *throttled.WaitGroup) {
	defer twg.Done()
	_, err := p.client.PutRecord(&kinesis.PutRecordInput{
		Data:         msg.Data,
		StreamName:   aws.String(msg.Stream),
		PartitionKey: aws.String(msg.PartitionKey),
	})
	log.Debug("KinesisStreamProducer: flushed single record")
	if err != nil {
		p.handleError(msg, err, "", "KinesisStreamProducer: PutRecord request failed")
	} else if p.config.AckSuccess {
		p.successes <- msg
	}
}