-
Notifications
You must be signed in to change notification settings - Fork 726
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
client/http: add more API for lightning's usage, and don't use body io.Reader #7534
Conversation
Signed-off-by: lance6716 <[email protected]>
[REVIEW NOTIFICATION] This pull request has been approved by:
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. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7534 +/- ##
==========================================
+ Coverage 74.48% 74.64% +0.16%
==========================================
Files 453 454 +1
Lines 50079 50142 +63
==========================================
+ Hits 37300 37428 +128
+ Misses 9439 9382 -57
+ Partials 3340 3332 -8
Flags with carried forward coverage won't be shown. Click here to find out more. |
/auto-cc |
@@ -271,7 +275,7 @@ func (c *client) request( | |||
zap.String("caller-id", c.callerID), | |||
} | |||
log.Debug("[pd] request the http url", logFields...) | |||
req, err := http.NewRequestWithContext(ctx, method, url, body) | |||
req, err := http.NewRequestWithContext(ctx, method, url, bytes.NewBuffer(body)) |
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 body
is nil, is it OK to pass it into the bytes.NewBuffer
? Should we add a check to use http.NoBody
like before?
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.
nil is OK, IDE shows other packages uses bytes.NewBuffer(nil)
safely.
client/http/client.go
Outdated
} | ||
|
||
// PostSchedulerDelay changes the delay of given scheduler. | ||
func (c *client) PostSchedulerDelay(ctx context.Context, scheduler string, delaySec int64) 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.
Do we need tests for these two interfaces?
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.
Sorry currently I don't know how to create the scheduler in http client tests so they can not be covered.
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 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 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.
updated. PTAL
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
client/http/client.go
Outdated
@@ -44,6 +44,7 @@ const ( | |||
// Client is a PD (Placement Driver) HTTP client. | |||
type Client interface { | |||
/* Meta-related interfaces */ | |||
GetClusterVersion(context.Context) (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.
Maybe it's better to move it into the config-related section.
client/http/client.go
Outdated
@@ -65,6 +67,7 @@ type Client interface { | |||
/* Scheduler-related interfaces */ | |||
GetSchedulers(context.Context) ([]string, error) | |||
CreateScheduler(ctx context.Context, name string, storeID uint64) error | |||
PostSchedulerDelay(context.Context, string, int64) 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.
PostSchedulerDelay(context.Context, string, int64) error | |
SetSchedulerDelay(context.Context, string, int64) error |
Signed-off-by: lance6716 <[email protected]>
/merge |
@lance6716: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
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. |
@lance6716: 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. |
/merge |
@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
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. |
This pull request has been accepted and is ready to merge. Commit hash: c89be3a
|
/build |
/retest |
@lance6716: Your PR was out of date, I have automatically updated it for you. If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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. |
What problem does this PR solve?
Issue Number: ref #7300
What is changed and how does it work?
add HTTP client API for lightning's using (BR not included)
port pdutil: fix retry reusing body reader pingcap/tidb#48312
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note