mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
remove mincache EOS related feature from upstream (#20375)
This commit is contained in:
238
internal/config/cache/cache.go
vendored
238
internal/config/cache/cache.go
vendored
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
}
|
||||
48
internal/config/cache/help.go
vendored
48
internal/config/cache/help.go
vendored
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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,
|
||||
},
|
||||
}
|
||||
)
|
||||
111
internal/config/cache/remote.go
vendored
111
internal/config/cache/remote.go
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
795
internal/config/cache/remote_gen.go
vendored
795
internal/config/cache/remote_gen.go
vendored
@@ -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
|
||||
}
|
||||
236
internal/config/cache/remote_gen_test.go
vendored
236
internal/config/cache/remote_gen_test.go
vendored
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user