@@ -47,6 +47,7 @@ type kafkaSinkClientV2 struct {
47
47
recordResize func (numRecords int64 )
48
48
49
49
topicsForConnectionCheck []string
50
+ createTopicsManually bool
50
51
51
52
// we need to fetch and keep track of this ourselves since kgo doesnt expose metadata to us
52
53
metadataMu struct {
@@ -68,6 +69,7 @@ func newKafkaSinkClientV2(
68
69
knobs kafkaSinkV2Knobs ,
69
70
mb metricsRecorderBuilder ,
70
71
topicsForConnectionCheck []string ,
72
+ createTopics changefeedbase.CreateKafkaTopics ,
71
73
) (* kafkaSinkClientV2 , error ) {
72
74
bootstrapBrokers := strings .Split (bootstrapAddrsStr , `,` )
73
75
@@ -82,8 +84,6 @@ func newKafkaSinkClientV2(
82
84
kgo .ProducerBatchMaxBytes (256 << 20 ), // 256MiB
83
85
kgo .BrokerMaxWriteBytes (1 << 30 ), // 1GiB
84
86
85
- kgo .AllowAutoTopicCreation (),
86
-
87
87
kgo .RecordRetries (5 ),
88
88
// This applies only to non-produce requests, ie the ListTopics call.
89
89
kgo .RequestRetries (5 ),
@@ -95,6 +95,10 @@ func newKafkaSinkClientV2(
95
95
}),
96
96
}
97
97
98
+ if createTopics == changefeedbase .CreateKafkaTopicsAuto {
99
+ baseOpts = append (baseOpts , kgo .AllowAutoTopicCreation ())
100
+ }
101
+
98
102
recordResize := func (numRecords int64 ) {}
99
103
if m := mb (requiresResourceAccounting ); m != nil { // `m` can be nil in tests.
100
104
baseOpts = append (baseOpts , kgo .WithHooks (& kgoMetricsAdapter {throttling : m .getKafkaThrottlingMetrics (settings )}))
@@ -128,6 +132,7 @@ func newKafkaSinkClientV2(
128
132
includeErrorDetails : changefeedbase .KafkaV2ErrorDetailsEnabled .Get (& settings .SV ),
129
133
recordResize : recordResize ,
130
134
topicsForConnectionCheck : topicsForConnectionCheck ,
135
+ createTopicsManually : createTopics == changefeedbase .CreateKafkaTopicsYes ,
131
136
}
132
137
c .metadataMu .allTopicPartitions = make (map [string ][]int32 )
133
138
@@ -361,6 +366,7 @@ func makeKafkaSinkV2(
361
366
settings * cluster.Settings ,
362
367
mb metricsRecorderBuilder ,
363
368
knobs kafkaSinkV2Knobs ,
369
+ createTopics changefeedbase.CreateKafkaTopics ,
364
370
) (Sink , error ) {
365
371
batchCfg , retryOpts , err := getSinkConfigFromJson (jsonConfig , sinkJSONConfig {
366
372
// Defaults from the v1 sink - flush immediately.
@@ -400,7 +406,7 @@ func makeKafkaSinkV2(
400
406
}
401
407
402
408
topicsForConnectionCheck := topicNamer .DisplayNamesSlice ()
403
- client , err := newKafkaSinkClientV2 (ctx , clientOpts , batchCfg , u .Host , settings , knobs , mb , topicsForConnectionCheck )
409
+ client , err := newKafkaSinkClientV2 (ctx , clientOpts , batchCfg , u .Host , settings , knobs , mb , topicsForConnectionCheck , createTopics )
404
410
if err != nil {
405
411
return nil , err
406
412
}
0 commit comments