Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH - Set message max bytes #27

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ Configuration variables with prefix are first loaded and then without prefix. Fo

A big value here can increase the heap memory of the application as all the payload that have to be sent to Kafka will be maintained in channel.

#### KAFKA_MESSAGE_MAX_BYTES
*Type*: integer

*Description*: The maximum message size in bytes at the producer level (default: 1024*1024)

#### LOG_CLI_VERBOSE
*Type*: boolean

Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Kafka struct {
Topic string `config:"KAFKA_TOPIC"`
ProduceChannelSize int `config:"KAFKA_PRODUCE_CHANNEL_SIZE"`
WithDecorators bool `config:"KAFKA_WITH_DECORATORS"`
MessageMaxBytes int `config:"KAFKA_MESSAGE_MAX_BYTES"`
}

// NewBase returns a new base configuration
Expand Down Expand Up @@ -107,6 +108,7 @@ func NewBase(ctx context.Context, configPrefix string) *Base {
Topic: "kafka-mongo-watcher",
ProduceChannelSize: 10000,
WithDecorators: true,
MessageMaxBytes: 1024 * 1024,
},
}

Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var cfg = &Base{
Topic: "kafka-mongo-watcher",
ProduceChannelSize: 10000,
WithDecorators: true,
MessageMaxBytes: 1024 * 1024,
},
}

Expand Down
1 change: 1 addition & 0 deletions internal/service/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func (container *Container) GetKafkaProducer() *kafkaconfluent.Producer {
producer, err := kafkaconfluent.NewProducer(&kafkaconfluent.ConfigMap{
"bootstrap.servers": container.Cfg.Kafka.BootstrapServers,
"go.produce.channel.size": container.Cfg.Kafka.ProduceChannelSize,
"message.max.bytes": container.Cfg.Kafka.MessageMaxBytes,
})
if err != nil {
panic(err)
Expand Down