-
Notifications
You must be signed in to change notification settings - Fork 324
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
fix: fix print message id without batch index #1211
Conversation
Signed-off-by: PennyYoon <525296438@qq.com>
@@ -184,7 +184,7 @@ func (id *messageID) BatchSize() int32 { | |||
} | |||
|
|||
func (id *messageID) String() string { | |||
return fmt.Sprintf("%d:%d:%d", id.ledgerID, id.entryID, id.partitionIdx) | |||
return fmt.Sprintf("%d:%d:%d:%d", id.ledgerID, id.entryID, id.partitionIdx, id.batchIdx) |
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 batchIndex = -1, do we still need to print it?
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 keep it consistent with the Java client. Don't print the batch index when it's -1.
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.
ok
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.
Please add the unit test case for it.
@@ -184,7 +184,7 @@ func (id *messageID) BatchSize() int32 { | |||
} | |||
|
|||
func (id *messageID) String() string { | |||
return fmt.Sprintf("%d:%d:%d", id.ledgerID, id.entryID, id.partitionIdx) | |||
return fmt.Sprintf("%d:%d:%d:%d", id.ledgerID, id.entryID, id.partitionIdx, id.batchIdx) |
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 keep it consistent with the Java client. Don't print the batch index when it's -1.
@RobertIndie, do we really need a unit test case for the |
I think it's worth adding these tests. This is a public method exposed to users, and we need to ensure the correctness of the returned content. Moreover, other tests also rely on this String's output. We can see that this change has caused failures in other tests in the CI. |
I understand the importance of writing test cases, and I won't insist on not writing them. However, I'd like to note that this part of the code logic is quite clear and straightforward. |
We write tests not because the code is clear or complex, but to ensure the functionality behaves correctly. Even for simple code, I believe it's best to write tests to cover it. This is exactly why the metric of test coverage is important. |
@RobertIndie Fair enough, thanks for your explanation. I won't block this review. |
I think the unit test case ran fail is because
If we need to fix test case, we can replace |
It seems more works than I expect, I have no time to work on this. |
(If this PR fixes a github issue, please add
Fixes #<xyz>
.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>
to link to the master issue.)Master Issue: #
Motivation
I found that different payload had the same message id
Modifications
append batch index when call string method of MessageID
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation