Add crawler delay config + dynamic config values (#11018)

This commit is contained in:
Klaus Post
2020-12-04 09:32:35 -08:00
committed by GitHub
parent e083471ec4
commit a896125490
19 changed files with 440 additions and 89 deletions

9
pkg/env/env.go vendored
View File

@@ -24,10 +24,19 @@ import (
var (
privateMutex sync.RWMutex
lockEnvMutex sync.Mutex
envOff bool
)
// LockSetEnv locks modifications to environment.
// Call returned function to unlock.
func LockSetEnv() func() {
lockEnvMutex.Lock()
return lockEnvMutex.Unlock
}
// SetEnvOff - turns off env lookup
// A global lock above this MUST ensure that
func SetEnvOff() {
privateMutex.Lock()
defer privateMutex.Unlock()

View File

@@ -50,11 +50,19 @@ func (adm *AdminClient) DelConfigKV(ctx context.Context, k string) (err error) {
return nil
}
const (
// ConfigAppliedHeader is the header indicating whether the config was applied without requiring a restart.
ConfigAppliedHeader = "x-minio-config-applied"
// ConfigAppliedTrue is the value set in header if the config was applied.
ConfigAppliedTrue = "true"
)
// SetConfigKV - set key value config to server.
func (adm *AdminClient) SetConfigKV(ctx context.Context, kv string) (err error) {
func (adm *AdminClient) SetConfigKV(ctx context.Context, kv string) (restart bool, err error) {
econfigBytes, err := EncryptData(adm.getSecretKey(), []byte(kv))
if err != nil {
return err
return false, err
}
reqData := requestData{
@@ -67,14 +75,14 @@ func (adm *AdminClient) SetConfigKV(ctx context.Context, kv string) (err error)
defer closeResponse(resp)
if err != nil {
return err
return false, err
}
if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp)
return false, httpRespToErrorResponse(resp)
}
return nil
return resp.Header.Get(ConfigAppliedHeader) != ConfigAppliedTrue, nil
}
// GetConfigKV - returns the key, value of the requested key, incoming data is encrypted.