add record metadata (#195)
Some checks failed
coverage / build (push) Failing after 1m23s
test / test (push) Failing after 16m3s

add missing metadata
This commit is contained in:
2025-10-24 11:23:34 +03:00
committed by GitHub
parent d830f70157
commit b89760a2cb

View File

@@ -3,6 +3,7 @@ package kgo
import ( import (
"context" "context"
"fmt" "fmt"
"strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@@ -238,6 +239,11 @@ func (pc *consumer) consume() {
for _, hdr := range record.Headers { for _, hdr := range record.Headers {
p.msg.Header.Set(hdr.Key, string(hdr.Value)) p.msg.Header.Set(hdr.Key, string(hdr.Value))
} }
p.msg.Header.Set("Micro-Offset", strconv.FormatInt(record.Offset, 10))
p.msg.Header.Set("Micro-Partition", strconv.FormatInt(int64(record.Partition), 10))
p.msg.Header.Set("Micro-Topic", record.Topic)
p.msg.Header.Set("Micro-Key", string(record.Key))
p.msg.Header.Set("Micro-Timestamp", strconv.FormatInt(record.Timestamp.Unix(), 10))
if pc.kopts.Codec.String() == "noop" { if pc.kopts.Codec.String() == "noop" {
p.msg.Body = record.Value p.msg.Body = record.Value
} else if pc.opts.BodyOnly { } else if pc.opts.BodyOnly {