mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Kafka notify: support batched commits for queue store (#20377)
The items will be saved per target batch and will be committed to the queue store when the batch is full Also, periodically commit the batched items to the queue store based on configured commit_timeout; default is 30s; Bonus: compress queue store multi writes
This commit is contained in:
@@ -274,6 +274,18 @@ var (
|
||||
Optional: true,
|
||||
Type: "number",
|
||||
},
|
||||
config.HelpKV{
|
||||
Key: target.KafkaBatchSize,
|
||||
Description: "batch size of the events; used only when queue_dir is set",
|
||||
Optional: true,
|
||||
Type: "number",
|
||||
},
|
||||
config.HelpKV{
|
||||
Key: target.KafkaBatchCommitTimeout,
|
||||
Description: "commit timeout set for the batch; used only when batch_size > 1",
|
||||
Optional: true,
|
||||
Type: "duration",
|
||||
},
|
||||
}
|
||||
|
||||
HelpMQTT = config.HelpKVS{
|
||||
|
||||
@@ -374,6 +374,10 @@ var (
|
||||
Key: target.KafkaBatchSize,
|
||||
Value: "0",
|
||||
},
|
||||
config.KV{
|
||||
Key: target.KafkaBatchCommitTimeout,
|
||||
Value: "0s",
|
||||
},
|
||||
config.KV{
|
||||
Key: target.KafkaCompressionCodec,
|
||||
Value: "",
|
||||
@@ -463,14 +467,23 @@ func GetNotifyKafka(kafkaKVS map[string]config.KVS) (map[string]target.KafkaArgs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
batchCommitTimeoutEnv := target.EnvKafkaBatchCommitTimeout
|
||||
if k != config.Default {
|
||||
batchCommitTimeoutEnv = batchCommitTimeoutEnv + config.Default + k
|
||||
}
|
||||
batchCommitTimeout, err := time.ParseDuration(env.Get(batchCommitTimeoutEnv, kv.Get(target.KafkaBatchCommitTimeout)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
kafkaArgs := target.KafkaArgs{
|
||||
Enable: enabled,
|
||||
Brokers: brokers,
|
||||
Topic: env.Get(topicEnv, kv.Get(target.KafkaTopic)),
|
||||
QueueDir: env.Get(queueDirEnv, kv.Get(target.KafkaQueueDir)),
|
||||
QueueLimit: queueLimit,
|
||||
Version: env.Get(versionEnv, kv.Get(target.KafkaVersion)),
|
||||
BatchSize: uint32(batchSize),
|
||||
Enable: enabled,
|
||||
Brokers: brokers,
|
||||
Topic: env.Get(topicEnv, kv.Get(target.KafkaTopic)),
|
||||
QueueDir: env.Get(queueDirEnv, kv.Get(target.KafkaQueueDir)),
|
||||
QueueLimit: queueLimit,
|
||||
Version: env.Get(versionEnv, kv.Get(target.KafkaVersion)),
|
||||
BatchSize: uint32(batchSize),
|
||||
BatchCommitTimeout: batchCommitTimeout,
|
||||
}
|
||||
|
||||
tlsEnableEnv := target.EnvKafkaTLS
|
||||
|
||||
Reference in New Issue
Block a user