@@ -38,7 +38,6 @@ const (
3838 certificateAuthType = "certificate"
3939 clientCert = "clientCert"
4040 clientKey = "clientKey"
41- consumeRetryEnabled = "consumeRetryEnabled"
4241 consumeRetryInterval = "consumeRetryInterval"
4342 authType = "authType"
4443 passwordAuthType = "password"
@@ -50,6 +49,7 @@ const (
5049 consumerFetchDefault = "consumerFetchDefault"
5150 channelBufferSize = "channelBufferSize"
5251 valueSchemaType = "valueSchemaType"
52+ compression = "compression"
5353
5454 // Kafka client config default values.
5555 // Refresh interval < keep alive time so that way connection can be kept alive indefinitely if desired.
@@ -102,6 +102,10 @@ type KafkaMetadata struct {
102102 consumerFetchMin int32 `mapstructure:"-"`
103103 consumerFetchDefault int32 `mapstructure:"-"`
104104
105+ // configs for kafka producer
106+ Compression string `mapstructure:"compression"`
107+ internalCompression sarama.CompressionCodec `mapstructure:"-"`
108+
105109 // schema registry
106110 SchemaRegistryURL string `mapstructure:"schemaRegistryURL"`
107111 SchemaRegistryAPIKey string `mapstructure:"schemaRegistryAPIKey"`
@@ -149,6 +153,7 @@ func (k *Kafka) getKafkaMetadata(meta map[string]string) (*KafkaMetadata, error)
149153 ConsumeRetryEnabled : k .DefaultConsumeRetryEnabled ,
150154 ConsumeRetryInterval : 100 * time .Millisecond ,
151155 internalVersion : sarama .V2_0_0_0 , //nolint:nosnakecase
156+ internalCompression : sarama .CompressionNone ,
152157 channelBufferSize : 256 ,
153158 consumerFetchMin : 1 ,
154159 consumerFetchDefault : 1024 * 1024 ,
@@ -294,6 +299,14 @@ func (k *Kafka) getKafkaMetadata(meta map[string]string) (*KafkaMetadata, error)
294299 m .internalVersion = version
295300 }
296301
302+ if m .Compression != "" {
303+ compression , err := parseCompression (m .Compression )
304+ if err != nil {
305+ return nil , err
306+ }
307+ m .internalCompression = compression
308+ }
309+
297310 if val , ok := meta [channelBufferSize ]; ok && val != "" {
298311 v , err := strconv .Atoi (val )
299312 if err != nil {
0 commit comments