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

@ -15,7 +15,6 @@ type smtpConfig struct {
type kafkaConfig struct { type kafkaConfig struct {
Port int `envconfig:"KAFKA_PORT"` Port int `envconfig:"KAFKA_PORT"`
Partition int `envconfig:"KAFKA_PARTITION"`
Host string `envconfig:"KAFKA_HOST"` Host string `envconfig:"KAFKA_HOST"`
} }

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

Loading…
Cancel
Save