mirror of
https://github.com/minio/minio.git
synced 2025-11-25 20:16:10 -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"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -28,7 +29,7 @@ import (
|
||||
// ClearConfigHistoryKV - clears the config entry represented by restoreID.
|
||||
// optionally allows setting `all` as a special keyword to automatically
|
||||
// erase all config set history entires.
|
||||
func (adm *AdminClient) ClearConfigHistoryKV(restoreID string) (err error) {
|
||||
func (adm *AdminClient) ClearConfigHistoryKV(ctx context.Context, restoreID string) (err error) {
|
||||
v := url.Values{}
|
||||
v.Set("restoreId", restoreID)
|
||||
reqData := requestData{
|
||||
@@ -37,7 +38,7 @@ func (adm *AdminClient) ClearConfigHistoryKV(restoreID string) (err error) {
|
||||
}
|
||||
|
||||
// Execute DELETE on /minio/admin/v2/clear-config-history-kv
|
||||
resp, err := adm.executeMethod(http.MethodDelete, reqData)
|
||||
resp, err := adm.executeMethod(ctx, http.MethodDelete, reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
@@ -53,7 +54,7 @@ func (adm *AdminClient) ClearConfigHistoryKV(restoreID string) (err error) {
|
||||
|
||||
// RestoreConfigHistoryKV - Restore a previous config set history.
|
||||
// Input is a unique id which represents the previous setting.
|
||||
func (adm *AdminClient) RestoreConfigHistoryKV(restoreID string) (err error) {
|
||||
func (adm *AdminClient) RestoreConfigHistoryKV(ctx context.Context, restoreID string) (err error) {
|
||||
v := url.Values{}
|
||||
v.Set("restoreId", restoreID)
|
||||
reqData := requestData{
|
||||
@@ -62,7 +63,7 @@ func (adm *AdminClient) RestoreConfigHistoryKV(restoreID string) (err error) {
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v2/set-config-kv to set config key/value.
|
||||
resp, err := adm.executeMethod(http.MethodPut, reqData)
|
||||
resp, err := adm.executeMethod(ctx, http.MethodPut, reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
@@ -90,7 +91,7 @@ func (ch ConfigHistoryEntry) CreateTimeFormatted() string {
|
||||
}
|
||||
|
||||
// ListConfigHistoryKV - lists a slice of ConfigHistoryEntries sorted by createTime.
|
||||
func (adm *AdminClient) ListConfigHistoryKV(count int) ([]ConfigHistoryEntry, error) {
|
||||
func (adm *AdminClient) ListConfigHistoryKV(ctx context.Context, count int) ([]ConfigHistoryEntry, error) {
|
||||
if count == 0 {
|
||||
count = 10
|
||||
}
|
||||
@@ -98,7 +99,8 @@ func (adm *AdminClient) ListConfigHistoryKV(count int) ([]ConfigHistoryEntry, er
|
||||
v.Set("count", strconv.Itoa(count))
|
||||
|
||||
// Execute GET on /minio/admin/v2/list-config-history-kv
|
||||
resp, err := adm.executeMethod(http.MethodGet,
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodGet,
|
||||
requestData{
|
||||
relPath: adminAPIPrefix + "/list-config-history-kv",
|
||||
queryValues: v,
|
||||
|
||||
Reference in New Issue
Block a user