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:
Harshavardhana
2020-03-20 15:00:44 -07:00
committed by GitHub
parent 1ffa983a9d
commit ae654831aa
47 changed files with 398 additions and 213 deletions

View File

@@ -18,6 +18,7 @@
package madmin
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -53,11 +54,13 @@ func (l LockEntries) Swap(i, j int) {
}
// TopLocks - returns the oldest locks in a minio setup.
func (adm *AdminClient) TopLocks() (LockEntries, error) {
func (adm *AdminClient) TopLocks(ctx context.Context) (LockEntries, error) {
// Execute GET on /minio/admin/v2/top/locks
// to get the oldest locks in a minio setup.
resp, err := adm.executeMethod("GET",
requestData{relPath: adminAPIPrefix + "/top/locks"})
resp, err := adm.executeMethod(ctx,
http.MethodGet,
requestData{relPath: adminAPIPrefix + "/top/locks"},
)
defer closeResponse(resp)
if err != nil {
return nil, err