chore(notify.go): Clean up duplicate code in RetryStage.exec#4893
chore(notify.go): Clean up duplicate code in RetryStage.exec#4893SuperQ merged 1 commit intoprometheus:mainfrom
Conversation
|
Pinging @siavashs who seems to be active in this file :) |
75d3f15 to
63c95e1
Compare
The code in the two selects in case ctx is done is exactly the same. Remove the second copy, the first one will be reached via the for loop. Signed-off-by: Rudolf Thomas <rudolf.thomas@firma.seznam.cz>
63c95e1 to
8e6d197
Compare
|
First block: Non-blocking check at the start of each iteration to exit early if context is already done Both code blocks are required and correct, therefor I'm closing this PR. |
|
Let me clarify: The second block does exactly(!) what the first one does. Rather than copying the exact same non-trivial 12 lines of code to the second select's case, do nothing and the done context will be handled in the first select in the next iteration of the for loop. I'm agruing this is more readable than copying the code, because it's not obvious it is exactly the same code. I guess a comment could be added to clarify. @siavashs Please consired reopening, I'll add the comment if you think it makes things clearer. |
It does the same thing but under different circumstances. So it is not exactly the same. Furthermore, even if the code did the exact same thing, it is not causing an issue and is not a bug so there is no motivation to fix it. I welcome you to look at existing open issues for more impactful contributions to the project. Thank you |
|
Upon further discussion with other maintainers, the change is marked as valid. |
|
I do think the code is actually correct as is. The second select is blocking where the first is not. |
|
The code is correct as is, as well as after the proposed change. All I'm trying to eliminate is the duplicated (copy-pasted) block: I'm arguing it's more readable without the copy. |
|
Ok. I had a misread/misunderstanding there. Somehow I read this change as removing the |
|
Can anyone with the privileges please merge this, now that it has been approved? Or should I loop in anyone else? Cheers. |
|
cc @SuperQ to run CI and merge |
The code in the two selects in case ctx is done is exactly the same. Remove the second copy, the first one will be reached via the for loop.