-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[KIP-848] Tests for: dev_kip848_fix_fast_subscribe_or_unsubscribe #5026
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
[KIP-848] Tests for: dev_kip848_fix_fast_subscribe_or_unsubscribe #5026
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
0999c46 to
050b06c
Compare
050b06c to
93df6bf
Compare
93df6bf to
ad14022
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
ea0a133 to
312f6f6
Compare
tests/0045-subscribe_update.c
Outdated
| * for TOPICS_CNT topics */ | ||
| rd_sleep(1); | ||
|
|
||
| RD_ARRAY_FOREACH(topic, topics, i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for FOREACH call here. We are not using topic anywhere below. We can have a simple for loop here.
tests/0045-subscribe_update.c
Outdated
| RD_ARRAY_FOREACH(topic, topics, i) { | ||
| rd_free(topics[i]); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for FOREACH here as well. We can just use simple forloop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't agree, we have it for every other iterable type, the foreach in general is less typo error prone than writing the initialization and while condition every time. Of course it works only for arrays that are on stack on in structure where we can determine the full size with sizeof() but it's an improvement for these cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep the definition of RD_ARRAY_FOREACH if you feel like but here the topic is being accessed as topics[i].
If we are keeping RD_ARRAY_FOREACH then we should also have RD_ARRAY_FOREACH_INDEX(ELEM, ARRAY, INDEX) and have RD_ARRAY_FOREACH(ELEM, ARRAY) which internally uses RD_ARRAY_FOREACH_INDEX. We don't need index in FOREACH in general like other high level languages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine I add them. The index is only for when we need it so it can be a different directive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you feel like but here the topic is being accessed as topics[i].
right, I use topic here
tests/0045-subscribe_update.c
Outdated
| SUB_TEST("%s", with_rebalance_cb ? "with rebalance callback" | ||
| : "without rebalance callback"); | ||
|
|
||
| RD_ARRAY_FOREACH(topic, topics, i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for FOREACH here as simple for loop will work.
src/rd.h
Outdated
| #define RD_SIZEOF(TYPE, MEMBER) sizeof(((TYPE *)NULL)->MEMBER) | ||
| #define RD_OFFSETOF(TYPE, MEMBER) ((size_t) & (((TYPE *)NULL)->MEMBER)) | ||
| /** Array foreach */ | ||
| #define RD_ARRAY_FOREACH(ELEM, ARRAY, INDEX) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this foreach as not used in the PR.
pranavrth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more comments.
src/rd.h
Outdated
| INDEX < RD_ARRAY_SIZE(ARRAY); \ | ||
| (ELEM) = \ | ||
| (++INDEX < RD_ARRAY_SIZE(ARRAY) ? (ARRAY)[INDEX] : (ELEM))) | ||
| #define RD_ARRAY_FOREACH_INDEX(ELEM, ARRAY, INDEX, BLOCK) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not make it complex to understand. Remove BLOCK from here. It should be a simple FOREACH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that way we need to provide the index variable externally instead of defining it here and we need to use always RD_ARRAY_FOREACH_INDEX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep it simple to understand the functions. We should remove this BLOCK from the macro and make it work it without it. Something like below.
/** Array foreach */
#define RD_ARRAY_FOREACH_INDEX(ELEM, ARRAY, INDEX) \
for ((INDEX = 0, (ELEM) = (ARRAY)[INDEX]); \
INDEX < RD_ARRAY_SIZE(ARRAY); \
(ELEM) = \
(++INDEX < RD_ARRAY_SIZE(ARRAY) ? (ARRAY)[INDEX] : (ELEM)))
#define RD_ARRAY_FOREACH(ELEM, ARRAY) \
RD_ARRAY_FOREACH_INDEX(ELEM, ARRAY, __i)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are places in librdkafka where we expect a variable to be defined already. We can expect __i defined already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are places in librdkafka where we expect a variable to be defined already. We can expect __i defined already.
I don't like it because you've to define the variable outside it and the name is fixed, in that case it's better if we leave only the original RD_ARRAY_FOREACH passing the variable name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using C99 standard of declaring variable inside the for loop. Like for(int i=0;i<n;i++) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way it had problem with older versions of MSVC that didn't implement the C99 standard fully until some time ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I would prefer to remove this FOREACH loop altogether. But if you want to keep it, keep only RD_ARRAY_FOREACH_INDEX. Remove RD_ARRAY_FOREACH. So the implementation of original RD_ARRAY_FOREACH but with changed name RD_ARRAY_FOREACH_INDEX.
9722f04 to
7aea93f
Compare
…nsumer` group rebalance protocol
652cda5 to
7a4340a
Compare
pranavrth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!.
No description provided.