Skip to content

Commit

Permalink
Specify Kafka batch size (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Nov 19, 2024
1 parent e703a43 commit 6d26ccd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/kafkalib/writer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kafkalib

import (
"cmp"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -32,10 +33,7 @@ func newWriter(ctx context.Context, cfg config.Kafka) (*kafka.Writer, error) {
Compression: kafka.Gzip,
Transport: transport,
WriteTimeout: 5 * time.Second,
}

if cfg.MaxRequestSize > 0 {
writer.BatchBytes = int64(cfg.MaxRequestSize)
BatchBytes: cmp.Or(int64(cfg.MaxRequestSize), 1048576),
}

return writer, nil
Expand Down

0 comments on commit 6d26ccd

Please sign in to comment.