@@ -21,7 +21,7 @@ import (
2121// message object. It's designed to be used in Kafka consumers.
2222// One straightforward DecodeMessageFunc could be something that
2323// Avro decodes the message body to the concrete response type.
24- type DecodeMessageFunc func (context.Context , * sarama.ConsumerMessage ) (record * models.Record , err error )
24+ type DecodeMessageFunc func (context.Context , * sarama.ConsumerMessage , bool ) (record * models.Record , err error )
2525
2626const kafkaTimestampKey = "@timestamp"
2727const keyField = "key"
@@ -39,7 +39,7 @@ func (d *Decoder) DeserializerFor(recordType string) DecodeMessageFunc {
3939 }
4040}
4141
42- func (d * Decoder ) AvroMessageToRecord (context context.Context , msg * sarama.ConsumerMessage ) (* models.Record , error ) {
42+ func (d * Decoder ) AvroMessageToRecord (context context.Context , msg * sarama.ConsumerMessage , withKeyAndValue bool ) (* models.Record , error ) {
4343 if msg .Value == nil {
4444 return nil , e .ErrNilMessage
4545 }
@@ -63,7 +63,7 @@ func (d *Decoder) AvroMessageToRecord(context context.Context, msg *sarama.Consu
6363
6464 parsedNative [kafkaTimestampKey ] = makeTimestamp (msg .Timestamp )
6565
66- if msg .Key != nil {
66+ if withKeyAndValue && msg .Key != nil {
6767 nativeKey , err := d .nativeFromBinary (msg .Key )
6868 if err != nil {
6969 return nil , err
@@ -84,7 +84,7 @@ func makeTimestamp(timestamp time.Time) int64 {
8484 return timestamp .UnixNano () / int64 (time .Millisecond )
8585}
8686
87- func (d * Decoder ) JsonMessageToRecord (context context.Context , msg * sarama.ConsumerMessage ) (* models.Record , error ) {
87+ func (d * Decoder ) JsonMessageToRecord (context context.Context , msg * sarama.ConsumerMessage , withKeyAndValue bool ) (* models.Record , error ) {
8888 var jsonValue map [string ]interface {}
8989 err := json .Unmarshal (msg .Value , & jsonValue )
9090
0 commit comments