Sfoglia il codice sorgente

Add topic and partition to ConsumerEvent struct

Willem van Bergen 11 anni fa
parent
commit
b0c0c68111
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      consumer.go

+ 3 - 1
consumer.go

@@ -45,6 +45,8 @@ type ConsumerConfig struct {
 // a message (in which case Err is nil and the other fields are all set).
 type ConsumerEvent struct {
 	Key, Value []byte
+	Topic      string
+	Partition  int32
 	Offset     int64
 	Err        error
 }
@@ -280,7 +282,7 @@ func (c *Consumer) fetchMessages() {
 					close(c.events)
 					close(c.done)
 					return
-				case c.events <- &ConsumerEvent{Key: msg.Msg.Key, Value: msg.Msg.Value, Offset: msg.Offset}:
+				case c.events <- &ConsumerEvent{Key: msg.Msg.Key, Value: msg.Msg.Value, Offset: msg.Offset, Topic: c.topic, Partition: c.partition}:
 					c.offset++
 				}
 			}