-
Notifications
You must be signed in to change notification settings - Fork 725
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
api: supports /regions/key
by hex key
#8262
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
PTAL, thx! @yongman |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8262 +/- ##
==========================================
- Coverage 77.41% 77.33% -0.09%
==========================================
Files 471 471
Lines 61395 61405 +10
==========================================
- Hits 47529 47486 -43
- Misses 10314 10363 +49
- Partials 3552 3556 +4
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Can we add this new change to the PD HTTP SDK as well?
@yongman: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
The |
Signed-off-by: husharp <jinhao.hu@pingcap.com>
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.
rest lgtm
pkg/utils/apiutil/apiutil.go
Outdated
@@ -336,6 +336,22 @@ func ParseKey(name string, input map[string]any) ([]byte, string, error) { | |||
return returned, rawKey, nil | |||
} | |||
|
|||
// ParseHexKeys decodes hexadecimal keys to bytes if the format is "hex". | |||
func ParseHexKeys(format string, keys ...*string) error { |
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.
Returning parsed key to user is better than returning result by input parameter implicitly.
func ParseHexKeys(format string, keys ...*string) error { | |
func ParseHexKeys(format string, keys []string) ([]string, error) { |
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.
want to reduce redundant code :(
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 know what you want... But this suggestion aims to avoid to changing data in the input implicitly, and each update operation, I think, should re-assign to the old value. Let's see what other reviewers think.
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.
Perhaps there is no need to provide a function. Because of the multiple arguments and the error check which will make code more redundant.
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.
cc @JmPotato
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.
This involves converting between []byte
and string
. I prefer a more performant approach; a benchmark may help.
Signed-off-by: husharp <jinhao.hu@pingcap.com>
44aaf74
to
509c5fb
Compare
Signed-off-by: husharp <jinhao.hu@pingcap.com>
pkg/utils/apiutil/apiutil.go
Outdated
@@ -336,6 +336,22 @@ func ParseKey(name string, input map[string]any) ([]byte, string, error) { | |||
return returned, rawKey, nil | |||
} | |||
|
|||
// ParseHexKeys decodes hexadecimal keys to bytes if the format is "hex". | |||
func ParseHexKeys(format string, keys []string) (hexStrings []string, err error) { |
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.
func ParseHexKeys(format string, keys []string) (hexStrings []string, err error) { | |
func ParseHexKeys(format string, keys []string) (hexBytes [][]byte, err error) { |
returning bytes can reduce some converting
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.
changed in 3f515a6
which change hex.String
to hex.Decode
, PTAL, thx!
@okJiang: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
if format != "hex" { | ||
return keys, nil | ||
} |
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.
Shall we move it out of this function?
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, we only use it when the format is "hex" and want to extract common logic.
add more comment to ParseHexKeys
, PTAL, thx!
ref #8262 (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.
Since the function is named ParseHexKeys, I think it has already be in hex format before calling this function.
Signed-off-by: husharp <jinhao.hu@pingcap.com>
7e69cb1
to
3f515a6
Compare
Signed-off-by: husharp <jinhao.hu@pingcap.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JmPotato, nolouch, okJiang, yongman The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: Close #8261
What is changed and how does it work?
Check List
Tests
Release note