-
Notifications
You must be signed in to change notification settings - Fork 18
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: unsafe method panic, reduce log, slice work with id #77
Conversation
modules/queue/disk_queue/module.go
Outdated
//log.Debugf("save offset: %v", offset.EncodeToString()) | ||
|
||
err = kv.AddValue(ConsumerOffsetBucket, util.UnsafeStringToBytes(getCommitKey(k, consumer)), []byte(offset.EncodeToString())) | ||
err = kv.AddValue(ConsumerOffsetBucket, util.UnsafeGetStringToBytes(getCommitKey(k, consumer)), []byte(offset.EncodeToString())) |
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.
Why not fix UnsafeStringToBytes rather create another function with same behavior, i don't think it is necessary, and the output of getCommitKey
should not be empty, if empty you should call panic, i don't really get the case that you can fix with the change.
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.
when getCommitKey
not empty, the return []byte
just has len , but cap=0, so this k.AddValue
will panic
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.
What does this PR do
This pull request includes several updates and improvements across multiple files. The changes primarily involve enhancing logging messages for better clarity, adding error handling, and updating function implementations. Below are the most important changes grouped by theme:
Logging Improvements:
modules/queue/disk_queue/consumer.go
to include more detailed information, such asworkerID
. This improves traceability and debugging. [1] [2] [3] [4] [5] [6]plugins/elastic/bulk_indexing/bulk_indexing.go
to provide more context by including theworkerID
in log messages. This helps in identifying the specific worker handling the task. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Error Handling:
modules/queue/disk_queue/consumer.go
to provide more detailed error messages when encountering issues with message sizes. [1] [2]Function Implementations:
UnsafeGetStringToBytes
incore/util/bytes.go
to handle empty string cases and avoid nil slices. This function provides a safer alternative for converting strings to bytes.UnsafeStringToBytes
withUnsafeGetStringToBytes
inmodules/queue/disk_queue/module.go
to ensure the safer handling of string-to-byte conversions.Typographical Fixes:
getElasticsearchMeatadata
togetElasticsearchMetadata
inplugins/elastic/bulk_indexing/bulk_indexing.go
. [1] [2]These changes collectively improve the robustness, clarity, and maintainability of the codebase.
Rationale for this change
Standards checklist