slaventius 2 years ago
parent e2a6d8e9f8
commit 30f36a44b0
  1. 5
      internal/config/config.go
  2. 13
      internal/postman.go

@ -14,9 +14,8 @@ type smtpConfig struct {
}
type kafkaConfig struct {
Port int `envconfig:"KAFKA_PORT"`
Partition int `envconfig:"KAFKA_PARTITION"`
Host string `envconfig:"KAFKA_HOST"`
Port int `envconfig:"KAFKA_PORT"`
Host string `envconfig:"KAFKA_HOST"`
}
// ...

@ -3,10 +3,12 @@ package postman
import (
"context"
"encoding/json"
"fmt"
"log"
"net"
"strconv"
"test3k/authPostman/internal/config"
"time"
// smtp "test3k/authPostman/internal/smtp"
@ -31,10 +33,11 @@ func NewServer(ctx context.Context, config *config.Config, topic string) *AuthPo
kafkaReader: kafka.NewReader(kafka.ReaderConfig{
Topic: topic,
Brokers: []string{net.JoinHostPort(config.Kafka.Host, strconv.Itoa(config.Kafka.Port))},
// GroupID: fmt.Sprintf("consumer-group-%d", config.Kafka.Partition),
Partition: config.Kafka.Partition,
MinBytes: 10e3, // 10KB
MaxBytes: 10e6, // 10MB
GroupID: fmt.Sprintf("consumer-group-%s", topic),
// Partition: 0,
MinBytes: 10e3, // 10KB
MaxBytes: 10e6, // 10MB
ReadBackoffMax: time.Millisecond * 100,
}),
}
}
@ -45,7 +48,7 @@ func (s *AuthPostmanServer) GracefulStop() error {
func (s *AuthPostmanServer) ReadMessage(offset int64) error {
// ...
s.kafkaReader.SetOffset(offset)
// s.kafkaReader.SetOffset(offset)
//
for {

Loading…
Cancel
Save