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

[QC-1232] Improve log message when kafka broker url is missing #2437

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

justonedev1
Copy link
Collaborator

better error handling when kafkaBrokers are missing

{ "enable.auto.commit", { "true" } },
{ "auto.offset.reset", { "latest" } } } };
if (brokers.empty()) {
constexpr std::string_view message{ "You are trying to start KafkaPoller without any brokers" };
Copy link
Collaborator

Choose a reason for hiding this comment

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

why use a string_view here ?

@@ -68,8 +68,25 @@ std::string createKafkaGroupId(std::string_view prefix, std::string_view detecto
return groupId;
}

bool checkKafkaParams(const std::string& kafkaBrokers, const std::string& topic, const std::string_view triggerTypeLogId)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

genuine question: why don't you use a string_view for the first two arguments ?
I understand that the parameters you will give later in SOR are strings, but from the point of view of the interface, wouldn't it be better to have something uniform ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, all of these should be the same. Thanks for the remark
I generally prefer std::string_view over const std::string& because it is non owning and non allocating and read only class, so it 1) implies the usage, 2) allows you to use the function (generally speaking) allocating something/creating temporary string, 3) string_view can be used easily with wider range of classes: std::string, const char*, std::vector<char>, ... But in this case the choice does not really matter...

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok !

Co-authored-by: Piotr Konopka <piotr.jan.konopka@cern.ch>
@Barthelemy Barthelemy self-requested a review September 26, 2024 06:31
@Barthelemy Barthelemy enabled auto-merge (squash) September 26, 2024 06:31
@Barthelemy Barthelemy merged commit 4e33ac4 into AliceO2Group:master Sep 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants