You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
754 B

3 years ago
package kafka
import (
3 years ago
"context"
3 years ago
"github.com/segmentio/kafka-go"
)
type KafkaReader struct {
3 years ago
ctx context.Context
3 years ago
reader *kafka.Reader
3 years ago
first string
topic string
3 years ago
}
3 years ago
func NewReader(ctx context.Context, topic string, address ...string) *KafkaReader {
3 years ago
return &KafkaReader{
3 years ago
ctx: ctx,
3 years ago
reader: kafka.NewReader(kafka.ReaderConfig{
Topic: topic,
Brokers: address,
GroupID: "consumer-group-id", // TODO
Partition: 0, // TODO
MinBytes: 10e3, // 10KB
MaxBytes: 10e6, // 10MB
}),
first: address[0],
topic: topic,
3 years ago
}
}
func (s *KafkaReader) Close() error {
return s.reader.Close()
}
func (s *KafkaReader) ReadMessage(key string, value string) error {
return nil
}