MCPcopy Create free account
hub / github.com/IBM/sarama / AddControlRecordWithTimestamp

Method AddControlRecordWithTimestamp

fetch_response.go:686–718  ·  view source on GitHub ↗
(topic string, partition int32, offset int64, producerID int64, recordType ControlRecordType, timestamp time.Time)

Source from the content-addressed store, hash-verified

684}
685
686func (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
720func (r *FetchResponse) AddMessage(topic string, partition int32, key, value Encoder, offset int64) {
721 r.AddMessageWithTimestamp(topic, partition, key, value, offset, time.Time{}, 0)

Callers 1

AddControlRecordMethod · 0.95

Calls 5

getOrCreateBlockMethod · 0.95
encodeMethod · 0.95
addRecordMethod · 0.95
newDefaultRecordsFunction · 0.85
ByteEncoderTypeAlias · 0.85

Tested by

no test coverage detected