From 203266aaea3b4853ca93f36163def709573e61d8 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 28 Aug 2022 16:06:52 +0300 Subject: [PATCH] fix noop codec usage and body only Signed-off-by: Vasiliy Tolstov --- kgo.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kgo.go b/kgo.go index 6dc893f..1b8a337 100644 --- a/kgo.go +++ b/kgo.go @@ -264,13 +264,13 @@ func (k *kBroker) publish(ctx context.Context, msgs []*broker.Message, opts ...b for _, msg := range msgs { rec := &kgo.Record{Key: key} rec.Topic, _ = msg.Header.Get(metadata.HeaderTopic) - if options.BodyOnly { - rec.Value = msg.Body - } else if k.opts.Codec.String() == "noop" { + if k.opts.Codec.String() == "noop" { rec.Value = msg.Body for k, v := range msg.Header { rec.Headers = append(rec.Headers, kgo.RecordHeader{Key: k, Value: []byte(v)}) } + } else if options.BodyOnly { + rec.Value = msg.Body } else { rec.Value, err = k.opts.Codec.Marshal(msg) if err != nil {