From e2a6d8e9f84678e53e277fd66ec688579fbf7684 Mon Sep 17 00:00:00 2001 From: slaventius Date: Thu, 2 Feb 2023 21:36:54 +0300 Subject: [PATCH] * --- internal/config/config.go | 5 +++-- internal/postman.go | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index cdb927b..db2edb4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,8 +14,9 @@ type smtpConfig struct { } type kafkaConfig struct { - Host string `envconfig:"KAFKA_HOST"` - Port int `envconfig:"KAFKA_PORT"` + Port int `envconfig:"KAFKA_PORT"` + Partition int `envconfig:"KAFKA_PARTITION"` + Host string `envconfig:"KAFKA_HOST"` } // ... diff --git a/internal/postman.go b/internal/postman.go index 0ea6534..26b89ab 100644 --- a/internal/postman.go +++ b/internal/postman.go @@ -8,7 +8,7 @@ import ( "strconv" "test3k/authPostman/internal/config" - smtp "test3k/authPostman/internal/smtp" + // smtp "test3k/authPostman/internal/smtp" "github.com/segmentio/kafka-go" ) @@ -29,10 +29,10 @@ func NewServer(ctx context.Context, config *config.Config, topic string) *AuthPo ctx: ctx, config: config, kafkaReader: kafka.NewReader(kafka.ReaderConfig{ - Topic: topic, - Brokers: []string{net.JoinHostPort(config.Kafka.Host, strconv.Itoa(config.Kafka.Port))}, - GroupID: "consumer-group-id", - Partition: 0, + 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 }), @@ -65,16 +65,16 @@ func (s *AuthPostmanServer) ReadMessage(offset int64) error { log.Printf("send code %s to %s ...", amsg.Code, amsg.Email) // log.Printf("message at offset %d: %s = %s\n", m.Offset, string(m.Key), string(m.Value)) - // - message := smtp.NewMessage("Confirmation code", amsg.Code) - message.AppendRecipient(amsg.Email) + // // + // message := smtp.NewMessage("Confirmation code", amsg.Code) + // message.AppendRecipient(amsg.Email) - // - smtpSender := smtp.NewService(s.config.Smtp.Host, s.config.Smtp.Port, s.config.Smtp.Sender, s.config.Smtp.Password) - ers := smtpSender.Send(message) - if ers != nil { - log.Print(ers) - } + // // + // smtpSender := smtp.NewService(s.config.Smtp.Host, s.config.Smtp.Port, s.config.Smtp.Sender, s.config.Smtp.Password) + // ers := smtpSender.Send(message) + // if ers != nil { + // log.Print(ers) + // } log.Printf("send code %s to %s completed", amsg.Code, amsg.Email) }