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

feat kafka-config: Better errors for kafka outdated configurations #857

Open
wants to merge 1 commit into
base: develop
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
15 changes: 13 additions & 2 deletions kafka/src/kafka/impl/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,19 @@ ProducerConfiguration Parse(const yaml_config::YamlConfig& config, formats::pars
producer.security = config.As<SecurityConfiguration>();
producer.rd_kafka_options = config["rd_kafka_custom_options"].As<RdKafkaOptions>({});
producer.delivery_timeout = config["delivery_timeout"].As<std::chrono::milliseconds>(producer.delivery_timeout);
producer.queue_buffering_max =
config["queue_buffering_max"].As<std::chrono::milliseconds>(producer.queue_buffering_max);
// Handle gradual transition of renaming, done in versions 2.3 -> 2.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this makes a lot of sense, because currently we have version 2.7 and your changes would be committed only in 2.8(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that API break, but it can not be undone

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only force config validation can protect against such API-break changes

// https://github.com/userver-framework/userver/issues/856
if (config.HasMember("queue_buffering_max_ms")) {
if (config.HasMember("queue_buffering_max")) {
throw std::runtime_error{"ProducerConfiguration options 'queue_buffering_max_ms' and 'queue_buffering_max' are mutually exclusive. Use 'queue_buffering_max' instead, since other is deprecated"};
}
LOG_WARNING() << "ProducerConfiguration option 'queue_buffering_max_ms' is deprecated. Use 'queue_buffering_max' instead";
producer.queue_buffering_max =
config["queue_buffering_max_ms"].As<std::chrono::milliseconds>(producer.queue_buffering_max);
} else {
producer.queue_buffering_max =
config["queue_buffering_max"].As<std::chrono::milliseconds>(producer.queue_buffering_max);
}
producer.enable_idempotence = config["enable_idempotence"].As<bool>(producer.enable_idempotence);
producer.queue_buffering_max_messages =
config["queue_buffering_max_messages"].As<std::uint32_t>(producer.queue_buffering_max_messages);
Expand Down