Last active
July 25, 2021 04:02
-
-
Save garystafford/0b2ac85a289ce38d926989fa29245b6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"github.com/segmentio/kafka-go" | |
) | |
func consume(ctx context.Context) { | |
dialer := saslScramDialer() | |
r := kafka.NewReader(kafka.ReaderConfig{ | |
Brokers: brokers, | |
Topic: topic2, | |
GroupID: group, | |
Logger: kafka.LoggerFunc(log.Debugf), | |
Dialer: dialer, | |
}) | |
for { | |
msg, err := r.ReadMessage(ctx) | |
if err != nil { | |
log.Panicf("%v could not read message: %v", getHostname(), err.Error()) | |
} | |
log.Debugf("%v received message: %v", getHostname(), string(msg.Value)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment