(topic string, partition int32, offset int64, producerID int64, recordType ControlRecordType, timestamp time.Time)
| 684 | } |
| 685 | |
| 686 | func (r *FetchResponse) AddControlRecordWithTimestamp(topic string, partition int32, offset int64, producerID int64, recordType ControlRecordType, timestamp time.Time) { |
| 687 | frb := r.getOrCreateBlock(topic, partition) |
| 688 | |
| 689 | // batch |
| 690 | batch := &RecordBatch{ |
| 691 | Version: 2, |
| 692 | LogAppendTime: r.LogAppendTime, |
| 693 | FirstTimestamp: timestamp, |
| 694 | MaxTimestamp: r.Timestamp, |
| 695 | FirstOffset: offset, |
| 696 | LastOffsetDelta: 0, |
| 697 | ProducerID: producerID, |
| 698 | IsTransactional: true, |
| 699 | Control: true, |
| 700 | } |
| 701 | |
| 702 | // records |
| 703 | records := newDefaultRecords(nil) |
| 704 | records.RecordBatch = batch |
| 705 | |
| 706 | // record |
| 707 | crAbort := ControlRecord{ |
| 708 | Version: 0, |
| 709 | Type: recordType, |
| 710 | } |
| 711 | crKey := &realEncoder{raw: make([]byte, 4)} |
| 712 | crValue := &realEncoder{raw: make([]byte, 6)} |
| 713 | crAbort.encode(crKey, crValue) |
| 714 | rec := &Record{Key: ByteEncoder(crKey.raw), Value: ByteEncoder(crValue.raw), OffsetDelta: 0, TimestampDelta: timestamp.Sub(batch.FirstTimestamp)} |
| 715 | batch.addRecord(rec) |
| 716 | |
| 717 | frb.RecordsSet = append(frb.RecordsSet, &records) |
| 718 | } |
| 719 | |
| 720 | func (r *FetchResponse) AddMessage(topic string, partition int32, key, value Encoder, offset int64) { |
| 721 | r.AddMessageWithTimestamp(topic, partition, key, value, offset, time.Time{}, 0) |
no test coverage detected