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

2 years ago
package kafka
import (
2 years ago
"context"
2 years ago
"github.com/segmentio/kafka-go"
)
type KafkaReader struct {
2 years ago
ctx context.Context
2 years ago
reader *kafka.Reader
2 years ago
first string
topic string
2 years ago
}
2 years ago
func NewReader(ctx context.Context, topic string, address ...string) *KafkaReader {
2 years ago
return &KafkaReader{
2 years ago
ctx: ctx,
2 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,
2 years ago
}
}
func (s *KafkaReader) Close() error {
return s.reader.Close()
}
func (s *KafkaReader) ReadMessage(key string, value string) error {
return nil
}