mirror of
https://github.com/minio/minio.git
synced 2025-11-22 10:37:42 -05:00
Add madmin package context support (#9172)
This is to improve responsiveness for all admin API operations and allowing callers to cancel any on-going admin operations, if they happen to be waiting too long.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package madmin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@@ -195,8 +196,8 @@ func (hri *HealResultItem) GetOnlineCounts() (b, a int) {
|
||||
// forceStart and forceStop are mutually exclusive, you can either
|
||||
// set one of them to 'true'. If both are set 'forceStart' will be
|
||||
// honored.
|
||||
func (adm *AdminClient) Heal(bucket, prefix string, healOpts HealOpts,
|
||||
clientToken string, forceStart, forceStop bool) (
|
||||
func (adm *AdminClient) Heal(ctx context.Context, bucket, prefix string,
|
||||
healOpts HealOpts, clientToken string, forceStart, forceStop bool) (
|
||||
healStart HealStartSuccess, healTaskStatus HealTaskStatus, err error) {
|
||||
|
||||
if forceStart && forceStop {
|
||||
@@ -227,11 +228,12 @@ func (adm *AdminClient) Heal(bucket, prefix string, healOpts HealOpts,
|
||||
queryVals.Set("forceStop", "true")
|
||||
}
|
||||
|
||||
resp, err := adm.executeMethod("POST", requestData{
|
||||
relPath: path,
|
||||
content: body,
|
||||
queryValues: queryVals,
|
||||
})
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodPost, requestData{
|
||||
relPath: path,
|
||||
content: body,
|
||||
queryValues: queryVals,
|
||||
})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return healStart, healTaskStatus, err
|
||||
@@ -279,9 +281,11 @@ type BgHealState struct {
|
||||
|
||||
// BackgroundHealStatus returns the background heal status of the
|
||||
// current server or cluster.
|
||||
func (adm *AdminClient) BackgroundHealStatus() (BgHealState, error) {
|
||||
func (adm *AdminClient) BackgroundHealStatus(ctx context.Context) (BgHealState, error) {
|
||||
// Execute POST request to background heal status api
|
||||
resp, err := adm.executeMethod("POST", requestData{relPath: adminAPIPrefix + "/background-heal/status"})
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodPost,
|
||||
requestData{relPath: adminAPIPrefix + "/background-heal/status"})
|
||||
if err != nil {
|
||||
return BgHealState{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user