Skip to content

Commit

Permalink
feat: unit type support
Browse files Browse the repository at this point in the history
  • Loading branch information
henesgokdag committed Nov 24, 2023
1 parent 438fd6e commit da86ad8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import (
"math"
"time"

"github.com/Trendyol/go-dcp/helpers"

"github.com/Trendyol/go-dcp/config"
)

type Kafka struct {
ProducerBatchBytes any `yaml:"producerBatchBytes"`
CollectionTopicMapping map[string]string `yaml:"collectionTopicMapping"`
InterCAPath string `yaml:"interCAPath"`
ScramUsername string `yaml:"scramUsername"`
Expand All @@ -16,9 +19,8 @@ type Kafka struct {
ClientID string `yaml:"clientID"`
Brokers []string `yaml:"brokers"`
MetadataTopics []string `yaml:"metadataTopics"`
ProducerBatchBytes int64 `yaml:"producerBatchBytes"`
ProducerBatchTimeout time.Duration `yaml:"producerBatchTimeout"`
ProducerMaxAttempts int `yaml:"producerMaxAttempts"`
ProducerBatchTimeout time.Duration `yaml:"producerBatchTimeout"`
ReadTimeout time.Duration `yaml:"readTimeout"`
WriteTimeout time.Duration `yaml:"writeTimeout"`
RequiredAcks int `yaml:"requiredAcks"`
Expand Down Expand Up @@ -60,7 +62,7 @@ func (c *Connector) ApplyDefaults() {
}

if c.Kafka.ProducerBatchBytes == 0 {
c.Kafka.ProducerBatchBytes = 10485760
c.Kafka.ProducerBatchBytes = helpers.ResolveUnionIntOrStringValue("10mb")
}

if c.Kafka.RequiredAcks == 0 {
Expand Down
4 changes: 3 additions & 1 deletion kafka/producer/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package producer
import (
"time"

"github.com/Trendyol/go-dcp/helpers"

"github.com/Trendyol/go-dcp-kafka/config"
gKafka "github.com/Trendyol/go-dcp-kafka/kafka"
"github.com/Trendyol/go-dcp/models"
Expand All @@ -29,7 +31,7 @@ func NewProducer(kafkaClient gKafka.Client,
config.Kafka.ProducerBatchTickerDuration,
writer,
config.Kafka.ProducerBatchSize,
config.Kafka.ProducerBatchBytes,
int64(helpers.ResolveUnionIntOrStringValue(config.Kafka.ProducerBatchBytes)),
dcpCheckpointCommit,
),
}, nil
Expand Down

0 comments on commit da86ad8

Please sign in to comment.