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

Add auto topic creation to writer config #1279

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
36 changes: 20 additions & 16 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ type WriterConfig struct {
// ErrorLogger is the logger used to report errors. If nil, the writer falls
// back to using Logger instead.
ErrorLogger Logger

// AllowAutoTopicCreation notifies writer to create topic if missing.
AllowAutoTopicCreation bool
}

type topicPartition struct {
Expand Down Expand Up @@ -487,22 +490,23 @@ func NewWriter(config WriterConfig) *Writer {
}

w := &Writer{
Addr: TCP(config.Brokers...),
Topic: config.Topic,
MaxAttempts: config.MaxAttempts,
BatchSize: config.BatchSize,
Balancer: config.Balancer,
BatchBytes: int64(config.BatchBytes),
BatchTimeout: config.BatchTimeout,
ReadTimeout: config.ReadTimeout,
WriteTimeout: config.WriteTimeout,
RequiredAcks: RequiredAcks(config.RequiredAcks),
Async: config.Async,
Logger: config.Logger,
ErrorLogger: config.ErrorLogger,
Transport: transport,
transport: transport,
writerStats: stats,
Addr: TCP(config.Brokers...),
Topic: config.Topic,
MaxAttempts: config.MaxAttempts,
BatchSize: config.BatchSize,
Balancer: config.Balancer,
BatchBytes: int64(config.BatchBytes),
BatchTimeout: config.BatchTimeout,
ReadTimeout: config.ReadTimeout,
WriteTimeout: config.WriteTimeout,
RequiredAcks: RequiredAcks(config.RequiredAcks),
Async: config.Async,
Logger: config.Logger,
ErrorLogger: config.ErrorLogger,
Transport: transport,
AllowAutoTopicCreation: config.AllowAutoTopicCreation,
transport: transport,
writerStats: stats,
}

if config.RequiredAcks == 0 {
Expand Down