github.com/tuingking/flamingo@v0.0.0-20220403134817-2796ae0e84ca/infra/kafka/config.go (about) 1 package kafka 2 3 import "github.com/segmentio/kafka-go" 4 5 type KafkaConfig struct { 6 Enable bool 7 Brokers []string 8 GroupID string 9 10 Producer struct { 11 Ack string 12 } 13 14 Consumer struct { 15 MinBytes int // min buffer bytes, IMPORTANT: need to set MaxByte if MinBytes is set 16 MaxBytes int // max qty of data that the cluster can response with when polled 17 MaxWait int 18 StartOffset int // earliest, 19 } 20 } 21 22 func InitReaderConfigDefault(topic string) kafka.ReaderConfig { 23 return kafka.ReaderConfig{ 24 Brokers: []string{"localhost:9092"}, 25 GroupID: "go.local.playground", 26 Topic: topic, 27 MinBytes: 10e3, // 10KB 28 MaxBytes: 10e6, // 10MB 29 } 30 }