diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 7aa7e2f51..2d4ab5d4d 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -669,8 +669,6 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, continue } - defer globalCacheConfig.Delete(bucket, dobj.ObjectName) - if replicateDeletes && (dobj.DeleteMarkerReplicationStatus() == replication.Pending || dobj.VersionPurgeStatus() == Pending) { // copy so we can re-add null ID. dobj := dobj diff --git a/cmd/config-current.go b/cmd/config-current.go index 24b4b9d71..1f627cdbc 100644 --- a/cmd/config-current.go +++ b/cmd/config-current.go @@ -34,7 +34,6 @@ import ( "github.com/minio/minio/internal/config" "github.com/minio/minio/internal/config/api" "github.com/minio/minio/internal/config/batch" - "github.com/minio/minio/internal/config/cache" "github.com/minio/minio/internal/config/callhome" "github.com/minio/minio/internal/config/compress" "github.com/minio/minio/internal/config/dns" @@ -80,7 +79,6 @@ func initHelp() { config.CallhomeSubSys: callhome.DefaultKVS, config.DriveSubSys: drive.DefaultKVS, config.ILMSubSys: ilm.DefaultKVS, - config.CacheSubSys: cache.DefaultKVS, config.BatchSubSys: batch.DefaultKVS, config.BrowserSubSys: browser.DefaultKVS, } @@ -229,12 +227,6 @@ func initHelp() { Key: config.EtcdSubSys, Description: "persist IAM assets externally to etcd", }, - config.HelpKV{ - Key: config.CacheSubSys, - Type: "string", - Description: "enable cache plugin on MinIO for GET/HEAD requests", - Optional: true, - }, config.HelpKV{ Key: config.BrowserSubSys, Description: "manage Browser HTTP specific features, such as Security headers, etc.", @@ -291,7 +283,6 @@ func initHelp() { config.SubnetSubSys: subnet.HelpSubnet, config.CallhomeSubSys: callhome.HelpCallhome, config.DriveSubSys: drive.HelpDrive, - config.CacheSubSys: cache.Help, config.BrowserSubSys: browser.Help, config.ILMSubSys: ilm.Help, } @@ -409,10 +400,6 @@ func validateSubSysConfig(ctx context.Context, s config.Config, subSys string, o if _, err := drive.LookupConfig(s[config.DriveSubSys][config.Default]); err != nil { return err } - case config.CacheSubSys: - if _, err := cache.LookupConfig(s[config.CacheSubSys][config.Default], globalRemoteTargetTransport); err != nil { - return err - } case config.PolicyOPASubSys: // In case legacy OPA config is being set, we treat it as if the // AuthZPlugin is being set. @@ -710,13 +697,6 @@ func applyDynamicConfigForSubSys(ctx context.Context, objAPI ObjectLayer, s conf configLogIf(ctx, fmt.Errorf("Unable to update drive config: %v", err)) } } - case config.CacheSubSys: - cacheCfg, err := cache.LookupConfig(s[config.CacheSubSys][config.Default], globalRemoteTargetTransport) - if err != nil { - configLogIf(ctx, fmt.Errorf("Unable to load cache config: %w", err)) - } else { - globalCacheConfig.Update(cacheCfg) - } case config.BrowserSubSys: browserCfg, err := browser.LookupConfig(s[config.BrowserSubSys][config.Default]) if err != nil { diff --git a/cmd/globals.go b/cmd/globals.go index 4f18c6b39..734e6abe2 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -41,7 +41,6 @@ import ( "github.com/dustin/go-humanize" "github.com/minio/minio/internal/auth" - "github.com/minio/minio/internal/config/cache" "github.com/minio/minio/internal/config/callhome" "github.com/minio/minio/internal/config/compress" "github.com/minio/minio/internal/config/dns" @@ -293,9 +292,6 @@ var ( // The global drive config globalDriveConfig drive.Config - // The global cache config - globalCacheConfig cache.Config - // Global server's network statistics globalConnStats = newConnStats() diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index f1bf1f5b7..60657234d 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -19,7 +19,6 @@ package cmd import ( "archive/tar" - "bytes" "context" "encoding/hex" "encoding/xml" @@ -36,7 +35,6 @@ import ( "strings" "sync/atomic" "time" - "unicode" "github.com/google/uuid" "github.com/klauspost/compress/gzhttp" @@ -50,7 +48,6 @@ import ( "github.com/minio/minio/internal/bucket/lifecycle" objectlock "github.com/minio/minio/internal/bucket/object/lock" "github.com/minio/minio/internal/bucket/replication" - "github.com/minio/minio/internal/config/cache" "github.com/minio/minio/internal/config/dns" "github.com/minio/minio/internal/config/storageclass" "github.com/minio/minio/internal/crypto" @@ -65,7 +62,6 @@ import ( "github.com/minio/minio/internal/s3select" "github.com/minio/mux" "github.com/minio/pkg/v3/policy" - "github.com/valyala/bytebufferpool" ) // supportedHeadGetReqParams - supported request parameters for GET and HEAD presigned request. @@ -383,96 +379,6 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj } } - cachedResult := globalCacheConfig.Enabled() && opts.VersionID == "" - if _, ok := crypto.IsRequested(r.Header); ok { - // No need to check cache for encrypted objects. - cachedResult = false - } - - var update bool - if cachedResult { - rc := &cache.CondCheck{} - h := r.Header.Clone() - if opts.PartNumber > 0 { - h.Set(xhttp.PartNumber, strconv.Itoa(opts.PartNumber)) - } - rc.Init(bucket, object, h) - - ci, err := globalCacheConfig.Get(rc) - if ci != nil { - tgs, ok := ci.Metadata[xhttp.AmzObjectTagging] - if ok { - // Set this such that authorization policies can be applied on the object tags. - r.Header.Set(xhttp.AmzObjectTagging, tgs) - } - - if s3Error := authorizeRequest(ctx, r, policy.GetObjectAction); s3Error != ErrNone { - writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(s3Error)) - return - } - - okSt := (ci.StatusCode == http.StatusOK || ci.StatusCode == http.StatusPartialContent || - ci.StatusCode == http.StatusPreconditionFailed || ci.StatusCode == http.StatusNotModified) - if okSt { - ci.WriteHeaders(w, func() { - // set common headers - setCommonHeaders(w) - }, func() { - okSt := (ci.StatusCode == http.StatusOK || ci.StatusCode == http.StatusPartialContent) - if okSt && len(ci.Data) > 0 { - for k, v := range ci.Metadata { - w.Header().Set(k, v) - } - - if opts.PartNumber > 0 && strings.Contains(ci.ETag, "-") { - w.Header()[xhttp.AmzMpPartsCount] = []string{ - strings.TrimLeftFunc(ci.ETag, func(r rune) bool { - return !unicode.IsNumber(r) - }), - } - } - - // For providing ranged content - start, rangeLen, err := rs.GetOffsetLength(ci.Size) - if err != nil { - start, rangeLen = 0, ci.Size - } - - // Set content length. - w.Header().Set(xhttp.ContentLength, strconv.FormatInt(rangeLen, 10)) - if rs != nil { - contentRange := fmt.Sprintf("bytes %d-%d/%d", start, start+rangeLen-1, ci.Size) - w.Header().Set(xhttp.ContentRange, contentRange) - } - - io.Copy(w, bytes.NewReader(ci.Data)) - return - } - if ci.StatusCode == http.StatusPreconditionFailed { - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrPreconditionFailed), r.URL) - return - } else if ci.StatusCode == http.StatusNotModified { - w.WriteHeader(ci.StatusCode) - return - } - - // We did not satisfy any requirement from the cache, update the cache. - // this basically means that we do not have the Data for the object - // cached yet - update = true - }) - if !update { - // No update is needed means we have written already to the client just return here. - return - } - } - } - - if errors.Is(err, cache.ErrKeyMissing) { - update = true - } - } - // Validate pre-conditions if any. opts.CheckPrecondFn = func(oi ObjectInfo) bool { if _, err := DecryptObjectInfo(&oi, r); err != nil { @@ -630,17 +536,8 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj setHeadGetRespHeaders(w, r.Form) - var buf *bytebufferpool.ByteBuffer - if update && globalCacheConfig.MatchesSize(objInfo.Size) { - buf = bytebufferpool.Get() - defer bytebufferpool.Put(buf) - } - var iw io.Writer iw = w - if buf != nil { - iw = io.MultiWriter(w, buf) - } statusCodeWritten := false httpWriter := xioutil.WriteOnClose(iw) @@ -667,31 +564,6 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj return } - defer func() { - var data []byte - if buf != nil { - data = buf.Bytes() - } - - if len(data) == 0 { - return - } - - globalCacheConfig.Set(&cache.ObjectInfo{ - Key: objInfo.Name, - Bucket: objInfo.Bucket, - ETag: objInfo.ETag, - ModTime: objInfo.ModTime, - Expires: objInfo.ExpiresStr(), - CacheControl: objInfo.CacheControl, - Metadata: cleanReservedKeys(objInfo.UserDefined), - Range: rangeHeader, - PartNumber: opts.PartNumber, - Size: int64(len(data)), - Data: data, - }) - }() - // Notify object accessed via a GET request. sendEvent(eventArgs{ EventName: event.ObjectAccessedGet, @@ -943,80 +815,6 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob } } - cachedResult := globalCacheConfig.Enabled() && opts.VersionID == "" - if _, ok := crypto.IsRequested(r.Header); ok { - // No need to check cache for encrypted objects. - cachedResult = false - } - if cachedResult { - rc := &cache.CondCheck{} - h := r.Header.Clone() - if opts.PartNumber > 0 { - h.Set(xhttp.PartNumber, strconv.Itoa(opts.PartNumber)) - } - rc.Init(bucket, object, h) - - ci, _ := globalCacheConfig.Get(rc) - if ci != nil { - tgs, ok := ci.Metadata[xhttp.AmzObjectTagging] - if ok { - // Set this such that authorization policies can be applied on the object tags. - r.Header.Set(xhttp.AmzObjectTagging, tgs) - } - - if s3Error := authorizeRequest(ctx, r, policy.GetObjectAction); s3Error != ErrNone { - writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(s3Error)) - return - } - - okSt := (ci.StatusCode == http.StatusOK || ci.StatusCode == http.StatusPartialContent || - ci.StatusCode == http.StatusPreconditionFailed || ci.StatusCode == http.StatusNotModified) - if okSt { - ci.WriteHeaders(w, func() { - // set common headers - setCommonHeaders(w) - }, func() { - okSt := (ci.StatusCode == http.StatusOK || ci.StatusCode == http.StatusPartialContent) - if okSt { - for k, v := range ci.Metadata { - w.Header().Set(k, v) - } - - // For providing ranged content - start, rangeLen, err := rs.GetOffsetLength(ci.Size) - if err != nil { - start, rangeLen = 0, ci.Size - } - - if opts.PartNumber > 0 && strings.Contains(ci.ETag, "-") { - w.Header()[xhttp.AmzMpPartsCount] = []string{ - strings.TrimLeftFunc(ci.ETag, func(r rune) bool { - return !unicode.IsNumber(r) - }), - } - } - - // Set content length for the range. - w.Header().Set(xhttp.ContentLength, strconv.FormatInt(rangeLen, 10)) - if rs != nil { - contentRange := fmt.Sprintf("bytes %d-%d/%d", start, start+rangeLen-1, ci.Size) - w.Header().Set(xhttp.ContentRange, contentRange) - } - - return - } - if ci.StatusCode == http.StatusPreconditionFailed { - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrPreconditionFailed), r.URL) - return - } - - w.WriteHeader(ci.StatusCode) - }) - return - } - } - } - opts.FastGetObjInfo = true objInfo, err := getObjectInfo(ctx, bucket, object, opts) @@ -2099,18 +1897,8 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req AutoEncrypt: globalAutoEncryption, }) - var buf *bytebufferpool.ByteBuffer - // Disable cache for encrypted objects - headers are applied with sseConfig.Apply if auto encrypted. - if globalCacheConfig.MatchesSize(size) && !crypto.Requested(r.Header) { - buf = bytebufferpool.Get() - defer bytebufferpool.Put(buf) - } - var reader io.Reader reader = rd - if buf != nil { - reader = io.TeeReader(rd, buf) - } actualSize := size var idxCb func() []byte @@ -2310,29 +2098,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req setPutObjHeaders(w, objInfo, false, r.Header) - defer func() { - var data []byte - if buf != nil { - data = buf.Bytes() - } - - if len(data) == 0 { - return - } - - globalCacheConfig.Set(&cache.ObjectInfo{ - Key: objInfo.Name, - Bucket: objInfo.Bucket, - ETag: objInfo.ETag, - ModTime: objInfo.ModTime, - Expires: objInfo.ExpiresStr(), - CacheControl: objInfo.CacheControl, - Size: int64(len(data)), - Metadata: cleanReservedKeys(objInfo.UserDefined), - Data: data, - }) - }() - // Notify object created event. evt := eventArgs{ EventName: event.ObjectCreatedPut, @@ -2881,8 +2646,6 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http. return } - defer globalCacheConfig.Delete(bucket, object) - setPutObjHeaders(w, objInfo, true, r.Header) writeSuccessNoContent(w) diff --git a/internal/config/cache/cache.go b/internal/config/cache/cache.go deleted file mode 100644 index bb97635c1..000000000 --- a/internal/config/cache/cache.go +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) 2015-2023 MinIO, Inc. -// -// This file is part of MinIO Object Storage stack -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package cache - -import ( - "bytes" - "context" - "errors" - "fmt" - "net/http" - "sync" - "time" - - "github.com/dustin/go-humanize" - "github.com/minio/minio/internal/config" - xhttp "github.com/minio/minio/internal/http" - "github.com/minio/pkg/v3/env" - "github.com/tinylib/msgp/msgp" -) - -// Cache related keys -const ( - Enable = "enable" - Endpoint = "endpoint" - BlockSize = "block_size" - - EnvEnable = "MINIO_CACHE_ENABLE" - EnvEndpoint = "MINIO_CACHE_ENDPOINT" - EnvBlockSize = "MINIO_CACHE_BLOCK_SIZE" -) - -// DefaultKVS - default KV config for cache settings -var DefaultKVS = config.KVS{ - config.KV{ - Key: Enable, - Value: "off", - }, - config.KV{ - Key: Endpoint, - Value: "", - }, - config.KV{ - Key: BlockSize, - Value: "", - }, -} - -// Config represents the subnet related configuration -type Config struct { - // Flag indicating whether cache is enabled. - Enable bool `json:"enable"` - - // Endpoint for caching uses remote mcache server to - // store and retrieve pre-condition check entities such as - // Etag and ModTime of an object + version - Endpoint string `json:"endpoint"` - - // BlockSize indicates the maximum object size below which - // data is cached and fetched remotely from DRAM. - BlockSize int64 - - // Is the HTTP client used for communicating with mcache server - clnt *http.Client -} - -var configLock sync.RWMutex - -// Enabled - indicates if cache is enabled or not -func (c *Config) Enabled() bool { - return c.Enable && c.Endpoint != "" -} - -// MatchesSize verifies if input 'size' falls under cacheable threshold -func (c Config) MatchesSize(size int64) bool { - configLock.RLock() - defer configLock.RUnlock() - - return c.Enable && c.BlockSize > 0 && size <= c.BlockSize -} - -// Update updates new cache frequency -func (c *Config) Update(ncfg Config) { - configLock.Lock() - defer configLock.Unlock() - - c.Enable = ncfg.Enable - c.Endpoint = ncfg.Endpoint - c.BlockSize = ncfg.BlockSize - c.clnt = ncfg.clnt -} - -// cache related errors -var ( - ErrInvalidArgument = errors.New("invalid argument") - ErrKeyMissing = errors.New("key is missing") -) - -const ( - mcacheV1Check = "/_mcache/v1/check" - mcacheV1Update = "/_mcache/v1/update" - mcacheV1Delete = "/_mcache/v1/delete" -) - -// Get performs conditional check and returns the cached object info if any. -func (c Config) Get(r *CondCheck) (*ObjectInfo, error) { - configLock.RLock() - defer configLock.RUnlock() - - if !c.Enable { - return nil, nil - } - - if c.Endpoint == "" { - // Endpoint not set, make this a no-op - return nil, nil - } - - buf, err := r.MarshalMsg(nil) - if err != nil { - return nil, err - } - - // We do not want Gets to take so much time, anything - // beyond 250ms we should cut it, remote cache is too - // busy already. - ctx, cancel := context.WithTimeout(context.Background(), 250*time.Millisecond) - defer cancel() - - req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.Endpoint+mcacheV1Check, bytes.NewReader(buf)) - if err != nil { - return nil, err - } - - resp, err := c.clnt.Do(req) - if err != nil { - return nil, err - } - defer xhttp.DrainBody(resp.Body) - - switch resp.StatusCode { - case http.StatusNotFound: - return nil, ErrKeyMissing - case http.StatusOK: - co := &ObjectInfo{} - return co, co.DecodeMsg(msgp.NewReader(resp.Body)) - default: - return nil, ErrInvalidArgument - } -} - -// Set sets the cache object info -func (c Config) Set(ci *ObjectInfo) { - configLock.RLock() - defer configLock.RUnlock() - - if !c.Enable { - return - } - - if c.Endpoint == "" { - // Endpoint not set, make this a no-op - return - } - - buf, err := ci.MarshalMsg(nil) - if err != nil { - return - } - - req, err := http.NewRequestWithContext(context.Background(), http.MethodPut, c.Endpoint+mcacheV1Update, bytes.NewReader(buf)) - if err != nil { - return - } - - resp, err := c.clnt.Do(req) - if err != nil { - return - } - defer xhttp.DrainBody(resp.Body) -} - -// Delete deletes remote cached content for object and its version. -func (c Config) Delete(bucket, key string) { - configLock.RLock() - defer configLock.RUnlock() - - if !c.Enable { - return - } - - if c.Endpoint == "" { - return - } - - req, err := http.NewRequestWithContext(context.Background(), http.MethodDelete, c.Endpoint+fmt.Sprintf("%s?bucket=%s&key=%s", mcacheV1Delete, bucket, key), nil) - if err != nil { - return - } - - resp, err := c.clnt.Do(req) - if err != nil { - return - } - defer xhttp.DrainBody(resp.Body) -} - -// LookupConfig - lookup config and override with valid environment settings if any. -func LookupConfig(kvs config.KVS, transport http.RoundTripper) (cfg Config, err error) { - cfg.Enable = env.Get(EnvEnable, kvs.GetWithDefault(Enable, DefaultKVS)) == config.EnableOn - - if d := env.Get(EnvBlockSize, kvs.GetWithDefault(BlockSize, DefaultKVS)); d != "" { - objectSize, err := humanize.ParseBytes(d) - if err != nil { - return cfg, err - } - cfg.BlockSize = int64(objectSize) - } - - cfg.Endpoint = env.Get(EnvEndpoint, kvs.GetWithDefault(Endpoint, DefaultKVS)) - cfg.clnt = &http.Client{Transport: transport} - - return cfg, nil -} diff --git a/internal/config/cache/help.go b/internal/config/cache/help.go deleted file mode 100644 index 7754b06d1..000000000 --- a/internal/config/cache/help.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2015-2023 MinIO, Inc. -// -// This file is part of MinIO Object Storage stack -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package cache - -import "github.com/minio/minio/internal/config" - -var ( - defaultHelpPostfix = func(key string) string { - return config.DefaultHelpPostfix(DefaultKVS, key) - } - - // Help - provides help for cache config - Help = config.HelpKVS{ - config.HelpKV{ - Key: Enable, - Type: "on|off", - Description: "set to enable remote cache plugin" + defaultHelpPostfix(Enable), - Optional: true, - }, - config.HelpKV{ - Key: Endpoint, - Type: "string", - Description: "remote cache endpoint for GET/HEAD object(s) metadata, data" + defaultHelpPostfix(Endpoint), - Optional: true, - }, - config.HelpKV{ - Key: BlockSize, - Type: "string", - Description: "cache all objects below the specified block size" + defaultHelpPostfix(BlockSize), - Optional: true, - }, - } -) diff --git a/internal/config/cache/remote.go b/internal/config/cache/remote.go deleted file mode 100644 index 8db4e2f55..000000000 --- a/internal/config/cache/remote.go +++ /dev/null @@ -1,111 +0,0 @@ -package cache - -import ( - "net/http" - "regexp" - "strconv" - "time" - - "github.com/minio/minio/internal/amztime" - xhttp "github.com/minio/minio/internal/http" -) - -//go:generate msgp -file=$GOFILE - -// ObjectInfo represents the object information cached remotely -type ObjectInfo struct { - Key string `json:"key"` - Bucket string `json:"bucket"` - ETag string `json:"etag"` - ModTime time.Time `json:"modTime"` - StatusCode int `json:"statusCode"` - - // Optional elements - CacheControl string `json:"cacheControl,omitempty" msg:",omitempty"` - Expires string `json:"expires,omitempty" msg:",omitempty"` - Metadata map[string]string `json:"metadata,omitempty" msg:",omitempty"` - Range string `json:"range,omitempty" msg:",omitempty"` - PartNumber int `json:"partNumber,omitempty" msg:",omitempty"` - Size int64 `json:"size,omitempty" msg:",omitempty"` // Full size of the object - Data []byte `json:"data,omitempty" msg:",omitempty"` // Data can container full data of the object or partial -} - -// WriteHeaders writes the response headers for conditional requests -func (oi ObjectInfo) WriteHeaders(w http.ResponseWriter, preamble, statusCode func()) { - preamble() - - if !oi.ModTime.IsZero() { - w.Header().Set(xhttp.LastModified, oi.ModTime.UTC().Format(http.TimeFormat)) - } - - if oi.ETag != "" { - w.Header()[xhttp.ETag] = []string{"\"" + oi.ETag + "\""} - } - - if oi.Expires != "" { - w.Header().Set(xhttp.Expires, oi.Expires) - } - - if oi.CacheControl != "" { - w.Header().Set(xhttp.CacheControl, oi.CacheControl) - } - - statusCode() -} - -// CondCheck represents the conditional request made to the remote cache -// for validation during GET/HEAD object requests. -type CondCheck struct { - ObjectInfo - IfMatch string `json:"ifMatch,omitempty" msg:",omitempty"` - IfNoneMatch string `json:"ifNoneMatch,omitempty" msg:",omitempty"` - IfModifiedSince *time.Time `json:"ifModSince,omitempty" msg:",omitempty"` - IfUnModifiedSince *time.Time `json:"ifUnmodSince,omitempty" msg:",omitempty"` - IfRange string `json:"ifRange,omitempty" msg:",omitempty"` - IfPartNumber int `json:"ifPartNumber,omitempty" msg:",omitempty"` -} - -// IsSet tells the cache lookup to avoid sending a request -func (r *CondCheck) IsSet() bool { - if r == nil { - return false - } - return r.IfMatch != "" || r.IfNoneMatch != "" || r.IfModifiedSince != nil || r.IfUnModifiedSince != nil || r.IfRange != "" -} - -var etagRegex = regexp.MustCompile("\"*?([^\"]*?)\"*?$") - -// canonicalizeETag returns ETag with leading and trailing double-quotes removed, -// if any present -func canonicalizeETag(etag string) string { - return etagRegex.ReplaceAllString(etag, "$1") -} - -// Init - populates the input values, initializes CondCheck -// before sending the request remotely. -func (r *CondCheck) Init(bucket, object string, header http.Header) { - r.Key = object - r.Bucket = bucket - - ifModifiedSinceHeader := header.Get(xhttp.IfModifiedSince) - if ifModifiedSinceHeader != "" { - if givenTime, err := amztime.ParseHeader(ifModifiedSinceHeader); err == nil { - r.IfModifiedSince = &givenTime - } - } - ifUnmodifiedSinceHeader := header.Get(xhttp.IfUnmodifiedSince) - if ifUnmodifiedSinceHeader != "" { - if givenTime, err := amztime.ParseHeader(ifUnmodifiedSinceHeader); err == nil { - r.IfUnModifiedSince = &givenTime - } - } - r.IfMatch = canonicalizeETag(header.Get(xhttp.IfMatch)) - r.IfNoneMatch = canonicalizeETag(header.Get(xhttp.IfNoneMatch)) - r.IfRange = header.Get(xhttp.Range) - ifPartNumberHeader := header.Get(xhttp.PartNumber) - if ifPartNumberHeader != "" { - if partNumber, err := strconv.Atoi(ifPartNumberHeader); err == nil { - r.IfPartNumber = partNumber - } - } -} diff --git a/internal/config/cache/remote_gen.go b/internal/config/cache/remote_gen.go deleted file mode 100644 index b6b7e7e62..000000000 --- a/internal/config/cache/remote_gen.go +++ /dev/null @@ -1,795 +0,0 @@ -package cache - -// Code generated by github.com/tinylib/msgp DO NOT EDIT. - -import ( - "time" - - "github.com/tinylib/msgp/msgp" -) - -// DecodeMsg implements msgp.Decodable -func (z *CondCheck) DecodeMsg(dc *msgp.Reader) (err error) { - var field []byte - _ = field - var zb0001 uint32 - zb0001, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err) - return - } - for zb0001 > 0 { - zb0001-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err) - return - } - switch msgp.UnsafeString(field) { - case "ObjectInfo": - err = z.ObjectInfo.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "ObjectInfo") - return - } - case "IfMatch": - z.IfMatch, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "IfMatch") - return - } - case "IfNoneMatch": - z.IfNoneMatch, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "IfNoneMatch") - return - } - case "IfModifiedSince": - if dc.IsNil() { - err = dc.ReadNil() - if err != nil { - err = msgp.WrapError(err, "IfModifiedSince") - return - } - z.IfModifiedSince = nil - } else { - if z.IfModifiedSince == nil { - z.IfModifiedSince = new(time.Time) - } - *z.IfModifiedSince, err = dc.ReadTime() - if err != nil { - err = msgp.WrapError(err, "IfModifiedSince") - return - } - } - case "IfUnModifiedSince": - if dc.IsNil() { - err = dc.ReadNil() - if err != nil { - err = msgp.WrapError(err, "IfUnModifiedSince") - return - } - z.IfUnModifiedSince = nil - } else { - if z.IfUnModifiedSince == nil { - z.IfUnModifiedSince = new(time.Time) - } - *z.IfUnModifiedSince, err = dc.ReadTime() - if err != nil { - err = msgp.WrapError(err, "IfUnModifiedSince") - return - } - } - case "IfRange": - z.IfRange, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "IfRange") - return - } - case "IfPartNumber": - z.IfPartNumber, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "IfPartNumber") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *CondCheck) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 7 - // write "ObjectInfo" - err = en.Append(0x87, 0xaa, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f) - if err != nil { - return - } - err = z.ObjectInfo.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "ObjectInfo") - return - } - // write "IfMatch" - err = en.Append(0xa7, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68) - if err != nil { - return - } - err = en.WriteString(z.IfMatch) - if err != nil { - err = msgp.WrapError(err, "IfMatch") - return - } - // write "IfNoneMatch" - err = en.Append(0xab, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68) - if err != nil { - return - } - err = en.WriteString(z.IfNoneMatch) - if err != nil { - err = msgp.WrapError(err, "IfNoneMatch") - return - } - // write "IfModifiedSince" - err = en.Append(0xaf, 0x49, 0x66, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, 0x69, 0x6e, 0x63, 0x65) - if err != nil { - return - } - if z.IfModifiedSince == nil { - err = en.WriteNil() - if err != nil { - return - } - } else { - err = en.WriteTime(*z.IfModifiedSince) - if err != nil { - err = msgp.WrapError(err, "IfModifiedSince") - return - } - } - // write "IfUnModifiedSince" - err = en.Append(0xb1, 0x49, 0x66, 0x55, 0x6e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, 0x69, 0x6e, 0x63, 0x65) - if err != nil { - return - } - if z.IfUnModifiedSince == nil { - err = en.WriteNil() - if err != nil { - return - } - } else { - err = en.WriteTime(*z.IfUnModifiedSince) - if err != nil { - err = msgp.WrapError(err, "IfUnModifiedSince") - return - } - } - // write "IfRange" - err = en.Append(0xa7, 0x49, 0x66, 0x52, 0x61, 0x6e, 0x67, 0x65) - if err != nil { - return - } - err = en.WriteString(z.IfRange) - if err != nil { - err = msgp.WrapError(err, "IfRange") - return - } - // write "IfPartNumber" - err = en.Append(0xac, 0x49, 0x66, 0x50, 0x61, 0x72, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72) - if err != nil { - return - } - err = en.WriteInt(z.IfPartNumber) - if err != nil { - err = msgp.WrapError(err, "IfPartNumber") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *CondCheck) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 7 - // string "ObjectInfo" - o = append(o, 0x87, 0xaa, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f) - o, err = z.ObjectInfo.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "ObjectInfo") - return - } - // string "IfMatch" - o = append(o, 0xa7, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68) - o = msgp.AppendString(o, z.IfMatch) - // string "IfNoneMatch" - o = append(o, 0xab, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68) - o = msgp.AppendString(o, z.IfNoneMatch) - // string "IfModifiedSince" - o = append(o, 0xaf, 0x49, 0x66, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, 0x69, 0x6e, 0x63, 0x65) - if z.IfModifiedSince == nil { - o = msgp.AppendNil(o) - } else { - o = msgp.AppendTime(o, *z.IfModifiedSince) - } - // string "IfUnModifiedSince" - o = append(o, 0xb1, 0x49, 0x66, 0x55, 0x6e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, 0x69, 0x6e, 0x63, 0x65) - if z.IfUnModifiedSince == nil { - o = msgp.AppendNil(o) - } else { - o = msgp.AppendTime(o, *z.IfUnModifiedSince) - } - // string "IfRange" - o = append(o, 0xa7, 0x49, 0x66, 0x52, 0x61, 0x6e, 0x67, 0x65) - o = msgp.AppendString(o, z.IfRange) - // string "IfPartNumber" - o = append(o, 0xac, 0x49, 0x66, 0x50, 0x61, 0x72, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72) - o = msgp.AppendInt(o, z.IfPartNumber) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *CondCheck) UnmarshalMsg(bts []byte) (o []byte, err error) { - var field []byte - _ = field - var zb0001 uint32 - zb0001, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - for zb0001 > 0 { - zb0001-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - switch msgp.UnsafeString(field) { - case "ObjectInfo": - bts, err = z.ObjectInfo.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "ObjectInfo") - return - } - case "IfMatch": - z.IfMatch, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IfMatch") - return - } - case "IfNoneMatch": - z.IfNoneMatch, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IfNoneMatch") - return - } - case "IfModifiedSince": - if msgp.IsNil(bts) { - bts, err = msgp.ReadNilBytes(bts) - if err != nil { - return - } - z.IfModifiedSince = nil - } else { - if z.IfModifiedSince == nil { - z.IfModifiedSince = new(time.Time) - } - *z.IfModifiedSince, bts, err = msgp.ReadTimeBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IfModifiedSince") - return - } - } - case "IfUnModifiedSince": - if msgp.IsNil(bts) { - bts, err = msgp.ReadNilBytes(bts) - if err != nil { - return - } - z.IfUnModifiedSince = nil - } else { - if z.IfUnModifiedSince == nil { - z.IfUnModifiedSince = new(time.Time) - } - *z.IfUnModifiedSince, bts, err = msgp.ReadTimeBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IfUnModifiedSince") - return - } - } - case "IfRange": - z.IfRange, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IfRange") - return - } - case "IfPartNumber": - z.IfPartNumber, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IfPartNumber") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z *CondCheck) Msgsize() (s int) { - s = 1 + 11 + z.ObjectInfo.Msgsize() + 8 + msgp.StringPrefixSize + len(z.IfMatch) + 12 + msgp.StringPrefixSize + len(z.IfNoneMatch) + 16 - if z.IfModifiedSince == nil { - s += msgp.NilSize - } else { - s += msgp.TimeSize - } - s += 18 - if z.IfUnModifiedSince == nil { - s += msgp.NilSize - } else { - s += msgp.TimeSize - } - s += 8 + msgp.StringPrefixSize + len(z.IfRange) + 13 + msgp.IntSize - return -} - -// DecodeMsg implements msgp.Decodable -func (z *ObjectInfo) DecodeMsg(dc *msgp.Reader) (err error) { - var field []byte - _ = field - var zb0001 uint32 - zb0001, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err) - return - } - for zb0001 > 0 { - zb0001-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Key, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Key") - return - } - case "Bucket": - z.Bucket, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - case "ETag": - z.ETag, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "ETag") - return - } - case "ModTime": - z.ModTime, err = dc.ReadTime() - if err != nil { - err = msgp.WrapError(err, "ModTime") - return - } - case "StatusCode": - z.StatusCode, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "StatusCode") - return - } - case "CacheControl": - z.CacheControl, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "CacheControl") - return - } - case "Expires": - z.Expires, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Expires") - return - } - case "Metadata": - var zb0002 uint32 - zb0002, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - if z.Metadata == nil { - z.Metadata = make(map[string]string, zb0002) - } else if len(z.Metadata) > 0 { - for key := range z.Metadata { - delete(z.Metadata, key) - } - } - for zb0002 > 0 { - zb0002-- - var za0001 string - var za0002 string - za0001, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - za0002, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0001) - return - } - z.Metadata[za0001] = za0002 - } - case "Range": - z.Range, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Range") - return - } - case "PartNumber": - z.PartNumber, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "PartNumber") - return - } - case "Size": - z.Size, err = dc.ReadInt64() - if err != nil { - err = msgp.WrapError(err, "Size") - return - } - case "Data": - z.Data, err = dc.ReadBytes(z.Data) - if err != nil { - err = msgp.WrapError(err, "Data") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *ObjectInfo) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 12 - // write "Key" - err = en.Append(0x8c, 0xa3, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Key) - if err != nil { - err = msgp.WrapError(err, "Key") - return - } - // write "Bucket" - err = en.Append(0xa6, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74) - if err != nil { - return - } - err = en.WriteString(z.Bucket) - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - // write "ETag" - err = en.Append(0xa4, 0x45, 0x54, 0x61, 0x67) - if err != nil { - return - } - err = en.WriteString(z.ETag) - if err != nil { - err = msgp.WrapError(err, "ETag") - return - } - // write "ModTime" - err = en.Append(0xa7, 0x4d, 0x6f, 0x64, 0x54, 0x69, 0x6d, 0x65) - if err != nil { - return - } - err = en.WriteTime(z.ModTime) - if err != nil { - err = msgp.WrapError(err, "ModTime") - return - } - // write "StatusCode" - err = en.Append(0xaa, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65) - if err != nil { - return - } - err = en.WriteInt(z.StatusCode) - if err != nil { - err = msgp.WrapError(err, "StatusCode") - return - } - // write "CacheControl" - err = en.Append(0xac, 0x43, 0x61, 0x63, 0x68, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c) - if err != nil { - return - } - err = en.WriteString(z.CacheControl) - if err != nil { - err = msgp.WrapError(err, "CacheControl") - return - } - // write "Expires" - err = en.Append(0xa7, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73) - if err != nil { - return - } - err = en.WriteString(z.Expires) - if err != nil { - err = msgp.WrapError(err, "Expires") - return - } - // write "Metadata" - err = en.Append(0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) - if err != nil { - return - } - err = en.WriteMapHeader(uint32(len(z.Metadata))) - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - for za0001, za0002 := range z.Metadata { - err = en.WriteString(za0001) - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - err = en.WriteString(za0002) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0001) - return - } - } - // write "Range" - err = en.Append(0xa5, 0x52, 0x61, 0x6e, 0x67, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Range) - if err != nil { - err = msgp.WrapError(err, "Range") - return - } - // write "PartNumber" - err = en.Append(0xaa, 0x50, 0x61, 0x72, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72) - if err != nil { - return - } - err = en.WriteInt(z.PartNumber) - if err != nil { - err = msgp.WrapError(err, "PartNumber") - return - } - // write "Size" - err = en.Append(0xa4, 0x53, 0x69, 0x7a, 0x65) - if err != nil { - return - } - err = en.WriteInt64(z.Size) - if err != nil { - err = msgp.WrapError(err, "Size") - return - } - // write "Data" - err = en.Append(0xa4, 0x44, 0x61, 0x74, 0x61) - if err != nil { - return - } - err = en.WriteBytes(z.Data) - if err != nil { - err = msgp.WrapError(err, "Data") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *ObjectInfo) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 12 - // string "Key" - o = append(o, 0x8c, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Key) - // string "Bucket" - o = append(o, 0xa6, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74) - o = msgp.AppendString(o, z.Bucket) - // string "ETag" - o = append(o, 0xa4, 0x45, 0x54, 0x61, 0x67) - o = msgp.AppendString(o, z.ETag) - // string "ModTime" - o = append(o, 0xa7, 0x4d, 0x6f, 0x64, 0x54, 0x69, 0x6d, 0x65) - o = msgp.AppendTime(o, z.ModTime) - // string "StatusCode" - o = append(o, 0xaa, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65) - o = msgp.AppendInt(o, z.StatusCode) - // string "CacheControl" - o = append(o, 0xac, 0x43, 0x61, 0x63, 0x68, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c) - o = msgp.AppendString(o, z.CacheControl) - // string "Expires" - o = append(o, 0xa7, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73) - o = msgp.AppendString(o, z.Expires) - // string "Metadata" - o = append(o, 0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) - o = msgp.AppendMapHeader(o, uint32(len(z.Metadata))) - for za0001, za0002 := range z.Metadata { - o = msgp.AppendString(o, za0001) - o = msgp.AppendString(o, za0002) - } - // string "Range" - o = append(o, 0xa5, 0x52, 0x61, 0x6e, 0x67, 0x65) - o = msgp.AppendString(o, z.Range) - // string "PartNumber" - o = append(o, 0xaa, 0x50, 0x61, 0x72, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72) - o = msgp.AppendInt(o, z.PartNumber) - // string "Size" - o = append(o, 0xa4, 0x53, 0x69, 0x7a, 0x65) - o = msgp.AppendInt64(o, z.Size) - // string "Data" - o = append(o, 0xa4, 0x44, 0x61, 0x74, 0x61) - o = msgp.AppendBytes(o, z.Data) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *ObjectInfo) UnmarshalMsg(bts []byte) (o []byte, err error) { - var field []byte - _ = field - var zb0001 uint32 - zb0001, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - for zb0001 > 0 { - zb0001-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Key, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Key") - return - } - case "Bucket": - z.Bucket, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - case "ETag": - z.ETag, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "ETag") - return - } - case "ModTime": - z.ModTime, bts, err = msgp.ReadTimeBytes(bts) - if err != nil { - err = msgp.WrapError(err, "ModTime") - return - } - case "StatusCode": - z.StatusCode, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "StatusCode") - return - } - case "CacheControl": - z.CacheControl, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "CacheControl") - return - } - case "Expires": - z.Expires, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Expires") - return - } - case "Metadata": - var zb0002 uint32 - zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - if z.Metadata == nil { - z.Metadata = make(map[string]string, zb0002) - } else if len(z.Metadata) > 0 { - for key := range z.Metadata { - delete(z.Metadata, key) - } - } - for zb0002 > 0 { - var za0001 string - var za0002 string - zb0002-- - za0001, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - za0002, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0001) - return - } - z.Metadata[za0001] = za0002 - } - case "Range": - z.Range, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Range") - return - } - case "PartNumber": - z.PartNumber, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "PartNumber") - return - } - case "Size": - z.Size, bts, err = msgp.ReadInt64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "Size") - return - } - case "Data": - z.Data, bts, err = msgp.ReadBytesBytes(bts, z.Data) - if err != nil { - err = msgp.WrapError(err, "Data") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z *ObjectInfo) Msgsize() (s int) { - s = 1 + 4 + msgp.StringPrefixSize + len(z.Key) + 7 + msgp.StringPrefixSize + len(z.Bucket) + 5 + msgp.StringPrefixSize + len(z.ETag) + 8 + msgp.TimeSize + 11 + msgp.IntSize + 13 + msgp.StringPrefixSize + len(z.CacheControl) + 8 + msgp.StringPrefixSize + len(z.Expires) + 9 + msgp.MapHeaderSize - if z.Metadata != nil { - for za0001, za0002 := range z.Metadata { - _ = za0002 - s += msgp.StringPrefixSize + len(za0001) + msgp.StringPrefixSize + len(za0002) - } - } - s += 6 + msgp.StringPrefixSize + len(z.Range) + 11 + msgp.IntSize + 5 + msgp.Int64Size + 5 + msgp.BytesPrefixSize + len(z.Data) - return -} diff --git a/internal/config/cache/remote_gen_test.go b/internal/config/cache/remote_gen_test.go deleted file mode 100644 index 86a1a2b92..000000000 --- a/internal/config/cache/remote_gen_test.go +++ /dev/null @@ -1,236 +0,0 @@ -package cache - -// Code generated by github.com/tinylib/msgp DO NOT EDIT. - -import ( - "bytes" - "testing" - - "github.com/tinylib/msgp/msgp" -) - -func TestMarshalUnmarshalCondCheck(t *testing.T) { - v := CondCheck{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgCondCheck(b *testing.B) { - v := CondCheck{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgCondCheck(b *testing.B) { - v := CondCheck{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalCondCheck(b *testing.B) { - v := CondCheck{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeCondCheck(t *testing.T) { - v := CondCheck{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeCondCheck Msgsize() is inaccurate") - } - - vn := CondCheck{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeCondCheck(b *testing.B) { - v := CondCheck{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeCondCheck(b *testing.B) { - v := CondCheck{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalObjectInfo(t *testing.T) { - v := ObjectInfo{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgObjectInfo(b *testing.B) { - v := ObjectInfo{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgObjectInfo(b *testing.B) { - v := ObjectInfo{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalObjectInfo(b *testing.B) { - v := ObjectInfo{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodeObjectInfo(t *testing.T) { - v := ObjectInfo{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeObjectInfo Msgsize() is inaccurate") - } - - vn := ObjectInfo{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodeObjectInfo(b *testing.B) { - v := ObjectInfo{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodeObjectInfo(b *testing.B) { - v := ObjectInfo{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/internal/config/config.go b/internal/config/config.go index f0074c682..6f3430eda 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -103,7 +103,6 @@ const ( IdentityLDAPSubSys = madmin.IdentityLDAPSubSys IdentityTLSSubSys = madmin.IdentityTLSSubSys IdentityPluginSubSys = madmin.IdentityPluginSubSys - CacheSubSys = madmin.CacheSubSys SiteSubSys = madmin.SiteSubSys RegionSubSys = madmin.RegionSubSys EtcdSubSys = madmin.EtcdSubSys @@ -189,7 +188,6 @@ var SubSystemsDynamic = set.CreateStringSet( AuditWebhookSubSys, AuditKafkaSubSys, StorageClassSubSys, - CacheSubSys, ILMSubSys, BatchSubSys, BrowserSubSys, @@ -200,7 +198,6 @@ var SubSystemsSingleTargets = set.CreateStringSet( SiteSubSys, RegionSubSys, EtcdSubSys, - CacheSubSys, APISubSys, StorageClassSubSys, CompressionSubSys,