From 743357415e2ef9d39819d5040b4f98756efed529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=2ESamet=20=C4=B0leri?= Date: Tue, 25 Jun 2024 17:36:37 +0300 Subject: [PATCH] feat: remove `kafka.producerBatchTimeout`, no need to expose (#89) * feat: remove `kafka.producerBatchTimeout`, no need to expose --- README.md | 1 - config/config.go | 5 ----- kafka/client.go | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 4c2831a..aef9735 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,6 @@ Check out on [go-dcp](https://github.com/Trendyol/go-dcp#configuration) | `kafka.brokers` | []string | yes | | Broker ip and port information | | `kafka.producerBatchSize` | integer | no | 2000 | Maximum message count for batch, if exceed flush will be triggered. | | `kafka.producerBatchBytes` | 64 bit integer | no | 10mb | Maximum size(byte) for batch, if exceed flush will be triggered. `10mb` is default. | -| `kafka.producerBatchTimeout` | time.duration | no | 1 nano second | Time limit on how often incomplete message batches will be flushed. | | `kafka.producerMaxAttempts` | int | no | math.MaxInt | Limit on how many attempts will be made to deliver a message. | | `kafka.producerBatchTickerDuration` | time.Duration | no | 10s | Batch is being flushed automatically at specific time intervals for long waiting messages in batch. | | `kafka.readTimeout` | time.Duration | no | 30s | segmentio/kafka-go - Timeout for read operations | diff --git a/config/config.go b/config/config.go index 035b227..6d6e371 100644 --- a/config/config.go +++ b/config/config.go @@ -22,7 +22,6 @@ type Kafka struct { Brokers []string `yaml:"brokers"` MetadataTopics []string `yaml:"metadataTopics"` ProducerMaxAttempts int `yaml:"producerMaxAttempts"` - ProducerBatchTimeout time.Duration `yaml:"producerBatchTimeout"` ReadTimeout time.Duration `yaml:"readTimeout"` WriteTimeout time.Duration `yaml:"writeTimeout"` RequiredAcks int `yaml:"requiredAcks"` @@ -97,8 +96,4 @@ func (c *Connector) ApplyDefaults() { if c.Kafka.ProducerMaxAttempts == 0 { c.Kafka.ProducerMaxAttempts = math.MaxInt } - - if c.Kafka.ProducerBatchTimeout == 0 { - c.Kafka.ProducerBatchTimeout = time.Nanosecond - } } diff --git a/kafka/client.go b/kafka/client.go index d07ed09..2628313 100644 --- a/kafka/client.go +++ b/kafka/client.go @@ -180,7 +180,7 @@ func (c *client) Producer() *kafka.Writer { Balancer: c.config.Kafka.GetBalancer(), BatchSize: c.config.Kafka.ProducerBatchSize, BatchBytes: math.MaxInt, - BatchTimeout: c.config.Kafka.ProducerBatchTimeout, + BatchTimeout: time.Nanosecond, MaxAttempts: c.config.Kafka.ProducerMaxAttempts, ReadTimeout: c.config.Kafka.ReadTimeout, WriteTimeout: c.config.Kafka.WriteTimeout,