diff --git a/cmd/batch-handlers.go b/cmd/batch-handlers.go index a5c7aff02..baa980e20 100644 --- a/cmd/batch-handlers.go +++ b/cmd/batch-handlers.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2022 MinIO, Inc. +// Copyright (c) 2015-2023 MinIO, Inc. // // This file is part of MinIO Object Storage stack // @@ -42,7 +42,6 @@ import ( "github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/encrypt" "github.com/minio/minio-go/v7/pkg/tags" - "github.com/minio/minio/internal/auth" "github.com/minio/minio/internal/crypto" "github.com/minio/minio/internal/hash" xhttp "github.com/minio/minio/internal/http" @@ -51,222 +50,10 @@ import ( "github.com/minio/pkg/console" "github.com/minio/pkg/env" iampolicy "github.com/minio/pkg/iam/policy" - "github.com/minio/pkg/wildcard" "github.com/minio/pkg/workers" "gopkg.in/yaml.v2" ) -// replicate: -// # source of the objects to be replicated -// source: -// type: "minio" -// bucket: "testbucket" -// prefix: "spark/" -// -// # optional flags based filtering criteria -// # for source objects -// flags: -// filter: -// newerThan: "7d" -// olderThan: "7d" -// createdAfter: "date" -// createdBefore: "date" -// tags: -// - key: "name" -// value: "value*" -// metadata: -// - key: "content-type" -// value: "image/*" -// notify: -// endpoint: "https://splunk-hec.dev.com" -// token: "Splunk ..." # e.g. "Bearer token" -// -// # target where the objects must be replicated -// target: -// type: "minio" -// bucket: "testbucket1" -// endpoint: "https://play.min.io" -// path: "on" -// credentials: -// accessKey: "minioadmin" -// secretKey: "minioadmin" -// sessionToken: "" - -// BatchJobReplicateKV is a datatype that holds key and values for filtering of objects -// used by metadata filter as well as tags based filtering. -type BatchJobReplicateKV struct { - Key string `yaml:"key" json:"key"` - Value string `yaml:"value" json:"value"` -} - -// Validate returns an error if key is empty -func (kv BatchJobReplicateKV) Validate() error { - if kv.Key == "" { - return errInvalidArgument - } - return nil -} - -// Empty indicates if kv is not set -func (kv BatchJobReplicateKV) Empty() bool { - return kv.Key == "" && kv.Value == "" -} - -// Match matches input kv with kv, value will be wildcard matched depending on the user input -func (kv BatchJobReplicateKV) Match(ikv BatchJobReplicateKV) bool { - if kv.Empty() { - return true - } - if strings.EqualFold(kv.Key, ikv.Key) { - return wildcard.Match(kv.Value, ikv.Value) - } - return false -} - -// BatchReplicateRetry datatype represents total retry attempts and delay between each retries. -type BatchReplicateRetry struct { - Attempts int `yaml:"attempts" json:"attempts"` // number of retry attempts - Delay time.Duration `yaml:"delay" json:"delay"` // delay between each retries -} - -// Validate validates input replicate retries. -func (r BatchReplicateRetry) Validate() error { - if r.Attempts < 0 { - return errInvalidArgument - } - - if r.Delay < 0 { - return errInvalidArgument - } - - return nil -} - -// BatchReplicateFilter holds all the filters currently supported for batch replication -type BatchReplicateFilter struct { - NewerThan time.Duration `yaml:"newerThan,omitempty" json:"newerThan"` - OlderThan time.Duration `yaml:"olderThan,omitempty" json:"olderThan"` - CreatedAfter time.Time `yaml:"createdAfter,omitempty" json:"createdAfter"` - CreatedBefore time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` - Tags []BatchJobReplicateKV `yaml:"tags,omitempty" json:"tags"` - Metadata []BatchJobReplicateKV `yaml:"metadata,omitempty" json:"metadata"` -} - -// BatchReplicateNotification success or failure notification endpoint for each job attempts -type BatchReplicateNotification struct { - Endpoint string `yaml:"endpoint" json:"endpoint"` - Token string `yaml:"token" json:"token"` -} - -// BatchJobReplicateFlags various configurations for replication job definition currently includes -// - filter -// - notify -// - retry -type BatchJobReplicateFlags struct { - Filter BatchReplicateFilter `yaml:"filter" json:"filter"` - Notify BatchReplicateNotification `yaml:"notify" json:"notify"` - Retry BatchReplicateRetry `yaml:"retry" json:"retry"` -} - -// BatchJobReplicateResourceType defines the type of batch jobs -type BatchJobReplicateResourceType string - -// Validate validates if the replicate resource type is recognized and supported -func (t BatchJobReplicateResourceType) Validate() error { - switch t { - case BatchJobReplicateResourceMinIO: - case BatchJobReplicateResourceS3: - default: - return errInvalidArgument - } - return nil -} - -func (t BatchJobReplicateResourceType) isMinio() bool { - return t == BatchJobReplicateResourceMinIO -} - -// Different types of batch jobs.. -const ( - BatchJobReplicateResourceMinIO BatchJobReplicateResourceType = "minio" - BatchJobReplicateResourceS3 BatchJobReplicateResourceType = "s3" - - // add future targets -) - -// BatchJobReplicateCredentials access credentials for batch replication it may -// be either for target or source. -type BatchJobReplicateCredentials struct { - AccessKey string `xml:"AccessKeyId" json:"accessKey,omitempty" yaml:"accessKey"` - SecretKey string `xml:"SecretAccessKey" json:"secretKey,omitempty" yaml:"secretKey"` - SessionToken string `xml:"SessionToken" json:"sessionToken,omitempty" yaml:"sessionToken"` -} - -// Empty indicates if credentials are not set -func (c BatchJobReplicateCredentials) Empty() bool { - return c.AccessKey == "" && c.SecretKey == "" && c.SessionToken == "" -} - -// Validate validates if credentials are valid -func (c BatchJobReplicateCredentials) Validate() error { - if !auth.IsAccessKeyValid(c.AccessKey) || !auth.IsSecretKeyValid(c.SecretKey) { - return errInvalidArgument - } - return nil -} - -// BatchJobReplicateTarget describes target element of the replication job that receives -// the filtered data from source -type BatchJobReplicateTarget struct { - Type BatchJobReplicateResourceType `yaml:"type" json:"type"` - Bucket string `yaml:"bucket" json:"bucket"` - Prefix string `yaml:"prefix" json:"prefix"` - Endpoint string `yaml:"endpoint" json:"endpoint"` - Path string `yaml:"path" json:"path"` - Creds BatchJobReplicateCredentials `yaml:"credentials" json:"credentials"` -} - -// ValidPath returns true if path is valid -func (t BatchJobReplicateTarget) ValidPath() bool { - return t.Path == "on" || t.Path == "off" || t.Path == "auto" || t.Path == "" -} - -// BatchJobReplicateSource describes source element of the replication job that is -// the source of the data for the target -type BatchJobReplicateSource struct { - Type BatchJobReplicateResourceType `yaml:"type" json:"type"` - Bucket string `yaml:"bucket" json:"bucket"` - Prefix string `yaml:"prefix" json:"prefix"` - Endpoint string `yaml:"endpoint" json:"endpoint"` - Path string `yaml:"path" json:"path"` - Creds BatchJobReplicateCredentials `yaml:"credentials" json:"credentials"` -} - -// ValidPath returns true if path is valid -func (s BatchJobReplicateSource) ValidPath() bool { - switch s.Path { - case "on", "off", "auto", "": - return true - default: - return false - } -} - -// BatchJobReplicateV1 v1 of batch job replication -type BatchJobReplicateV1 struct { - APIVersion string `yaml:"apiVersion" json:"apiVersion"` - Flags BatchJobReplicateFlags `yaml:"flags" json:"flags"` - Target BatchJobReplicateTarget `yaml:"target" json:"target"` - Source BatchJobReplicateSource `yaml:"source" json:"source"` - - clnt *miniogo.Core `msg:"-"` -} - -// RemoteToLocal returns true if source is remote and target is local -func (r BatchJobReplicateV1) RemoteToLocal() bool { - return !r.Source.Creds.Empty() -} - // BatchJobRequest this is an internal data structure not for external consumption. type BatchJobRequest struct { ID string `yaml:"-" json:"name"` @@ -516,7 +303,7 @@ func (r *BatchJobReplicateV1) StartFromSource(ctx context.Context, api ObjectLay } for _, kv := range r.Flags.Filter.Tags { for t, v := range tagMap { - if kv.Match(BatchJobReplicateKV{Key: t, Value: v}) { + if kv.Match(BatchJobKV{Key: t, Value: v}) { return true } } @@ -533,7 +320,7 @@ func (r *BatchJobReplicateV1) StartFromSource(ctx context.Context, api ObjectLay continue } // We only need to match x-amz-meta or standardHeaders - if kv.Match(BatchJobReplicateKV{Key: k, Value: v}) { + if kv.Match(BatchJobKV{Key: k, Value: v}) { return true } } @@ -1070,7 +857,7 @@ func (r *BatchJobReplicateV1) Start(ctx context.Context, api ObjectLayer, job Ba for _, kv := range r.Flags.Filter.Tags { for t, v := range tagMap { - if kv.Match(BatchJobReplicateKV{Key: t, Value: v}) { + if kv.Match(BatchJobKV{Key: t, Value: v}) { return true } } @@ -1087,7 +874,7 @@ func (r *BatchJobReplicateV1) Start(ctx context.Context, api ObjectLayer, job Ba continue } // We only need to match x-amz-meta or standardHeaders - if kv.Match(BatchJobReplicateKV{Key: k, Value: v}) { + if kv.Match(BatchJobKV{Key: k, Value: v}) { return true } } diff --git a/cmd/batch-handlers_gen.go b/cmd/batch-handlers_gen.go index 7d9327598..54c80baef 100644 --- a/cmd/batch-handlers_gen.go +++ b/cmd/batch-handlers_gen.go @@ -6,1528 +6,6 @@ import ( "github.com/tinylib/msgp/msgp" ) -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateCredentials) 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 "AccessKey": - z.AccessKey, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "AccessKey") - return - } - case "SecretKey": - z.SecretKey, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "SecretKey") - return - } - case "SessionToken": - z.SessionToken, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "SessionToken") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchJobReplicateCredentials) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 3 - // write "AccessKey" - err = en.Append(0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.AccessKey) - if err != nil { - err = msgp.WrapError(err, "AccessKey") - return - } - // write "SecretKey" - err = en.Append(0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.SecretKey) - if err != nil { - err = msgp.WrapError(err, "SecretKey") - return - } - // write "SessionToken" - err = en.Append(0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.SessionToken) - if err != nil { - err = msgp.WrapError(err, "SessionToken") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchJobReplicateCredentials) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 3 - // string "AccessKey" - o = append(o, 0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.AccessKey) - // string "SecretKey" - o = append(o, 0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.SecretKey) - // string "SessionToken" - o = append(o, 0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - o = msgp.AppendString(o, z.SessionToken) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateCredentials) 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 "AccessKey": - z.AccessKey, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "AccessKey") - return - } - case "SecretKey": - z.SecretKey, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "SecretKey") - return - } - case "SessionToken": - z.SessionToken, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "SessionToken") - 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 BatchJobReplicateCredentials) Msgsize() (s int) { - s = 1 + 10 + msgp.StringPrefixSize + len(z.AccessKey) + 10 + msgp.StringPrefixSize + len(z.SecretKey) + 13 + msgp.StringPrefixSize + len(z.SessionToken) - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateFlags) 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 "Filter": - err = z.Filter.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "Filter") - return - } - case "Notify": - var zb0002 uint32 - zb0002, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - for zb0002 > 0 { - zb0002-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - switch msgp.UnsafeString(field) { - case "Endpoint": - z.Notify.Endpoint, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Notify", "Endpoint") - return - } - case "Token": - z.Notify.Token, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Notify", "Token") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - } - } - case "Retry": - var zb0003 uint32 - zb0003, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - for zb0003 > 0 { - zb0003-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - switch msgp.UnsafeString(field) { - case "Attempts": - z.Retry.Attempts, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "Retry", "Attempts") - return - } - case "Delay": - z.Retry.Delay, err = dc.ReadDuration() - if err != nil { - err = msgp.WrapError(err, "Retry", "Delay") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - } - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *BatchJobReplicateFlags) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 3 - // write "Filter" - err = en.Append(0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) - if err != nil { - return - } - err = z.Filter.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "Filter") - return - } - // write "Notify" - err = en.Append(0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) - if err != nil { - return - } - // map header, size 2 - // write "Endpoint" - err = en.Append(0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - if err != nil { - return - } - err = en.WriteString(z.Notify.Endpoint) - if err != nil { - err = msgp.WrapError(err, "Notify", "Endpoint") - return - } - // write "Token" - err = en.Append(0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.Notify.Token) - if err != nil { - err = msgp.WrapError(err, "Notify", "Token") - return - } - // write "Retry" - err = en.Append(0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) - if err != nil { - return - } - // map header, size 2 - // write "Attempts" - err = en.Append(0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - if err != nil { - return - } - err = en.WriteInt(z.Retry.Attempts) - if err != nil { - err = msgp.WrapError(err, "Retry", "Attempts") - return - } - // write "Delay" - err = en.Append(0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - if err != nil { - return - } - err = en.WriteDuration(z.Retry.Delay) - if err != nil { - err = msgp.WrapError(err, "Retry", "Delay") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *BatchJobReplicateFlags) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 3 - // string "Filter" - o = append(o, 0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) - o, err = z.Filter.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "Filter") - return - } - // string "Notify" - o = append(o, 0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) - // map header, size 2 - // string "Endpoint" - o = append(o, 0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - o = msgp.AppendString(o, z.Notify.Endpoint) - // string "Token" - o = append(o, 0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - o = msgp.AppendString(o, z.Notify.Token) - // string "Retry" - o = append(o, 0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) - // map header, size 2 - // string "Attempts" - o = append(o, 0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - o = msgp.AppendInt(o, z.Retry.Attempts) - // string "Delay" - o = append(o, 0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - o = msgp.AppendDuration(o, z.Retry.Delay) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateFlags) 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 "Filter": - bts, err = z.Filter.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "Filter") - return - } - case "Notify": - var zb0002 uint32 - zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - for zb0002 > 0 { - zb0002-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - switch msgp.UnsafeString(field) { - case "Endpoint": - z.Notify.Endpoint, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Notify", "Endpoint") - return - } - case "Token": - z.Notify.Token, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Notify", "Token") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - } - } - case "Retry": - var zb0003 uint32 - zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - for zb0003 > 0 { - zb0003-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - switch msgp.UnsafeString(field) { - case "Attempts": - z.Retry.Attempts, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Retry", "Attempts") - return - } - case "Delay": - z.Retry.Delay, bts, err = msgp.ReadDurationBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Retry", "Delay") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Retry") - 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 *BatchJobReplicateFlags) Msgsize() (s int) { - s = 1 + 7 + z.Filter.Msgsize() + 7 + 1 + 9 + msgp.StringPrefixSize + len(z.Notify.Endpoint) + 6 + msgp.StringPrefixSize + len(z.Notify.Token) + 6 + 1 + 9 + msgp.IntSize + 6 + msgp.DurationSize - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateKV) 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 "Value": - z.Value, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Value") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchJobReplicateKV) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 2 - // write "Key" - err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Key) - if err != nil { - err = msgp.WrapError(err, "Key") - return - } - // write "Value" - err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Value) - if err != nil { - err = msgp.WrapError(err, "Value") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchJobReplicateKV) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 2 - // string "Key" - o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Key) - // string "Value" - o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - o = msgp.AppendString(o, z.Value) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateKV) 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 "Value": - z.Value, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Value") - 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 BatchJobReplicateKV) Msgsize() (s int) { - s = 1 + 4 + msgp.StringPrefixSize + len(z.Key) + 6 + msgp.StringPrefixSize + len(z.Value) - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateResourceType) DecodeMsg(dc *msgp.Reader) (err error) { - { - var zb0001 string - zb0001, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err) - return - } - (*z) = BatchJobReplicateResourceType(zb0001) - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchJobReplicateResourceType) EncodeMsg(en *msgp.Writer) (err error) { - err = en.WriteString(string(z)) - if err != nil { - err = msgp.WrapError(err) - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchJobReplicateResourceType) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - o = msgp.AppendString(o, string(z)) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateResourceType) UnmarshalMsg(bts []byte) (o []byte, err error) { - { - var zb0001 string - zb0001, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - (*z) = BatchJobReplicateResourceType(zb0001) - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z BatchJobReplicateResourceType) Msgsize() (s int) { - s = msgp.StringPrefixSize + len(string(z)) - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateSource) 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 "Type": - { - var zb0002 string - zb0002, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Type") - return - } - z.Type = BatchJobReplicateResourceType(zb0002) - } - case "Bucket": - z.Bucket, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - case "Prefix": - z.Prefix, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Prefix") - return - } - case "Endpoint": - z.Endpoint, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - case "Path": - z.Path, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Path") - return - } - case "Creds": - var zb0003 uint32 - zb0003, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - for zb0003 > 0 { - zb0003-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - switch msgp.UnsafeString(field) { - case "AccessKey": - z.Creds.AccessKey, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Creds", "AccessKey") - return - } - case "SecretKey": - z.Creds.SecretKey, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Creds", "SecretKey") - return - } - case "SessionToken": - z.Creds.SessionToken, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Creds", "SessionToken") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - } - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *BatchJobReplicateSource) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 6 - // write "Type" - err = en.Append(0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) - if err != nil { - return - } - err = en.WriteString(string(z.Type)) - if err != nil { - err = msgp.WrapError(err, "Type") - 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 "Prefix" - err = en.Append(0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) - if err != nil { - return - } - err = en.WriteString(z.Prefix) - if err != nil { - err = msgp.WrapError(err, "Prefix") - return - } - // write "Endpoint" - err = en.Append(0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - if err != nil { - return - } - err = en.WriteString(z.Endpoint) - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - // write "Path" - err = en.Append(0xa4, 0x50, 0x61, 0x74, 0x68) - if err != nil { - return - } - err = en.WriteString(z.Path) - if err != nil { - err = msgp.WrapError(err, "Path") - return - } - // write "Creds" - err = en.Append(0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) - if err != nil { - return - } - // map header, size 3 - // write "AccessKey" - err = en.Append(0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Creds.AccessKey) - if err != nil { - err = msgp.WrapError(err, "Creds", "AccessKey") - return - } - // write "SecretKey" - err = en.Append(0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Creds.SecretKey) - if err != nil { - err = msgp.WrapError(err, "Creds", "SecretKey") - return - } - // write "SessionToken" - err = en.Append(0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.Creds.SessionToken) - if err != nil { - err = msgp.WrapError(err, "Creds", "SessionToken") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *BatchJobReplicateSource) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 6 - // string "Type" - o = append(o, 0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) - o = msgp.AppendString(o, string(z.Type)) - // string "Bucket" - o = append(o, 0xa6, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74) - o = msgp.AppendString(o, z.Bucket) - // string "Prefix" - o = append(o, 0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) - o = msgp.AppendString(o, z.Prefix) - // string "Endpoint" - o = append(o, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - o = msgp.AppendString(o, z.Endpoint) - // string "Path" - o = append(o, 0xa4, 0x50, 0x61, 0x74, 0x68) - o = msgp.AppendString(o, z.Path) - // string "Creds" - o = append(o, 0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) - // map header, size 3 - // string "AccessKey" - o = append(o, 0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Creds.AccessKey) - // string "SecretKey" - o = append(o, 0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Creds.SecretKey) - // string "SessionToken" - o = append(o, 0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - o = msgp.AppendString(o, z.Creds.SessionToken) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateSource) 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 "Type": - { - var zb0002 string - zb0002, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Type") - return - } - z.Type = BatchJobReplicateResourceType(zb0002) - } - case "Bucket": - z.Bucket, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - case "Prefix": - z.Prefix, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Prefix") - return - } - case "Endpoint": - z.Endpoint, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - case "Path": - z.Path, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Path") - return - } - case "Creds": - var zb0003 uint32 - zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - for zb0003 > 0 { - zb0003-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - switch msgp.UnsafeString(field) { - case "AccessKey": - z.Creds.AccessKey, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds", "AccessKey") - return - } - case "SecretKey": - z.Creds.SecretKey, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds", "SecretKey") - return - } - case "SessionToken": - z.Creds.SessionToken, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds", "SessionToken") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Creds") - 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 *BatchJobReplicateSource) Msgsize() (s int) { - s = 1 + 5 + msgp.StringPrefixSize + len(string(z.Type)) + 7 + msgp.StringPrefixSize + len(z.Bucket) + 7 + msgp.StringPrefixSize + len(z.Prefix) + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 5 + msgp.StringPrefixSize + len(z.Path) + 6 + 1 + 10 + msgp.StringPrefixSize + len(z.Creds.AccessKey) + 10 + msgp.StringPrefixSize + len(z.Creds.SecretKey) + 13 + msgp.StringPrefixSize + len(z.Creds.SessionToken) - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateTarget) 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 "Type": - { - var zb0002 string - zb0002, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Type") - return - } - z.Type = BatchJobReplicateResourceType(zb0002) - } - case "Bucket": - z.Bucket, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - case "Prefix": - z.Prefix, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Prefix") - return - } - case "Endpoint": - z.Endpoint, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - case "Path": - z.Path, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Path") - return - } - case "Creds": - var zb0003 uint32 - zb0003, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - for zb0003 > 0 { - zb0003-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - switch msgp.UnsafeString(field) { - case "AccessKey": - z.Creds.AccessKey, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Creds", "AccessKey") - return - } - case "SecretKey": - z.Creds.SecretKey, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Creds", "SecretKey") - return - } - case "SessionToken": - z.Creds.SessionToken, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Creds", "SessionToken") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - } - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *BatchJobReplicateTarget) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 6 - // write "Type" - err = en.Append(0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) - if err != nil { - return - } - err = en.WriteString(string(z.Type)) - if err != nil { - err = msgp.WrapError(err, "Type") - 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 "Prefix" - err = en.Append(0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) - if err != nil { - return - } - err = en.WriteString(z.Prefix) - if err != nil { - err = msgp.WrapError(err, "Prefix") - return - } - // write "Endpoint" - err = en.Append(0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - if err != nil { - return - } - err = en.WriteString(z.Endpoint) - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - // write "Path" - err = en.Append(0xa4, 0x50, 0x61, 0x74, 0x68) - if err != nil { - return - } - err = en.WriteString(z.Path) - if err != nil { - err = msgp.WrapError(err, "Path") - return - } - // write "Creds" - err = en.Append(0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) - if err != nil { - return - } - // map header, size 3 - // write "AccessKey" - err = en.Append(0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Creds.AccessKey) - if err != nil { - err = msgp.WrapError(err, "Creds", "AccessKey") - return - } - // write "SecretKey" - err = en.Append(0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Creds.SecretKey) - if err != nil { - err = msgp.WrapError(err, "Creds", "SecretKey") - return - } - // write "SessionToken" - err = en.Append(0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.Creds.SessionToken) - if err != nil { - err = msgp.WrapError(err, "Creds", "SessionToken") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *BatchJobReplicateTarget) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 6 - // string "Type" - o = append(o, 0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) - o = msgp.AppendString(o, string(z.Type)) - // string "Bucket" - o = append(o, 0xa6, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74) - o = msgp.AppendString(o, z.Bucket) - // string "Prefix" - o = append(o, 0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) - o = msgp.AppendString(o, z.Prefix) - // string "Endpoint" - o = append(o, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - o = msgp.AppendString(o, z.Endpoint) - // string "Path" - o = append(o, 0xa4, 0x50, 0x61, 0x74, 0x68) - o = msgp.AppendString(o, z.Path) - // string "Creds" - o = append(o, 0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) - // map header, size 3 - // string "AccessKey" - o = append(o, 0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Creds.AccessKey) - // string "SecretKey" - o = append(o, 0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Creds.SecretKey) - // string "SessionToken" - o = append(o, 0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - o = msgp.AppendString(o, z.Creds.SessionToken) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateTarget) 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 "Type": - { - var zb0002 string - zb0002, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Type") - return - } - z.Type = BatchJobReplicateResourceType(zb0002) - } - case "Bucket": - z.Bucket, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Bucket") - return - } - case "Prefix": - z.Prefix, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Prefix") - return - } - case "Endpoint": - z.Endpoint, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - case "Path": - z.Path, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Path") - return - } - case "Creds": - var zb0003 uint32 - zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - for zb0003 > 0 { - zb0003-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Creds") - return - } - switch msgp.UnsafeString(field) { - case "AccessKey": - z.Creds.AccessKey, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds", "AccessKey") - return - } - case "SecretKey": - z.Creds.SecretKey, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds", "SecretKey") - return - } - case "SessionToken": - z.Creds.SessionToken, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Creds", "SessionToken") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Creds") - 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 *BatchJobReplicateTarget) Msgsize() (s int) { - s = 1 + 5 + msgp.StringPrefixSize + len(string(z.Type)) + 7 + msgp.StringPrefixSize + len(z.Bucket) + 7 + msgp.StringPrefixSize + len(z.Prefix) + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 5 + msgp.StringPrefixSize + len(z.Path) + 6 + 1 + 10 + msgp.StringPrefixSize + len(z.Creds.AccessKey) + 10 + msgp.StringPrefixSize + len(z.Creds.SecretKey) + 13 + msgp.StringPrefixSize + len(z.Creds.SessionToken) - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchJobReplicateV1) 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 "APIVersion": - z.APIVersion, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "APIVersion") - return - } - case "Flags": - err = z.Flags.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "Flags") - return - } - case "Target": - err = z.Target.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "Target") - return - } - case "Source": - err = z.Source.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "Source") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *BatchJobReplicateV1) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 4 - // write "APIVersion" - err = en.Append(0x84, 0xaa, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.APIVersion) - if err != nil { - err = msgp.WrapError(err, "APIVersion") - return - } - // write "Flags" - err = en.Append(0xa5, 0x46, 0x6c, 0x61, 0x67, 0x73) - if err != nil { - return - } - err = z.Flags.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "Flags") - return - } - // write "Target" - err = en.Append(0xa6, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74) - if err != nil { - return - } - err = z.Target.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "Target") - return - } - // write "Source" - err = en.Append(0xa6, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65) - if err != nil { - return - } - err = z.Source.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "Source") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *BatchJobReplicateV1) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 4 - // string "APIVersion" - o = append(o, 0x84, 0xaa, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e) - o = msgp.AppendString(o, z.APIVersion) - // string "Flags" - o = append(o, 0xa5, 0x46, 0x6c, 0x61, 0x67, 0x73) - o, err = z.Flags.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "Flags") - return - } - // string "Target" - o = append(o, 0xa6, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74) - o, err = z.Target.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "Target") - return - } - // string "Source" - o = append(o, 0xa6, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65) - o, err = z.Source.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "Source") - return - } - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchJobReplicateV1) 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 "APIVersion": - z.APIVersion, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "APIVersion") - return - } - case "Flags": - bts, err = z.Flags.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "Flags") - return - } - case "Target": - bts, err = z.Target.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "Target") - return - } - case "Source": - bts, err = z.Source.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "Source") - 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 *BatchJobReplicateV1) Msgsize() (s int) { - s = 1 + 11 + msgp.StringPrefixSize + len(z.APIVersion) + 6 + z.Flags.Msgsize() + 7 + z.Target.Msgsize() + 7 + z.Source.Msgsize() - return -} - // DecodeMsg implements msgp.Decodable func (z *BatchJobRequest) DecodeMsg(dc *msgp.Reader) (err error) { var field []byte @@ -1843,729 +321,6 @@ func (z *BatchJobRequest) Msgsize() (s int) { return } -// DecodeMsg implements msgp.Decodable -func (z *BatchReplicateFilter) 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 "NewerThan": - z.NewerThan, err = dc.ReadDuration() - if err != nil { - err = msgp.WrapError(err, "NewerThan") - return - } - case "OlderThan": - z.OlderThan, err = dc.ReadDuration() - if err != nil { - err = msgp.WrapError(err, "OlderThan") - return - } - case "CreatedAfter": - z.CreatedAfter, err = dc.ReadTime() - if err != nil { - err = msgp.WrapError(err, "CreatedAfter") - return - } - case "CreatedBefore": - z.CreatedBefore, err = dc.ReadTime() - if err != nil { - err = msgp.WrapError(err, "CreatedBefore") - return - } - case "Tags": - var zb0002 uint32 - zb0002, err = dc.ReadArrayHeader() - if err != nil { - err = msgp.WrapError(err, "Tags") - return - } - if cap(z.Tags) >= int(zb0002) { - z.Tags = (z.Tags)[:zb0002] - } else { - z.Tags = make([]BatchJobReplicateKV, zb0002) - } - for za0001 := range z.Tags { - var zb0003 uint32 - zb0003, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - for zb0003 > 0 { - zb0003-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Tags[za0001].Key, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Key") - return - } - case "Value": - z.Tags[za0001].Value, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Value") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - } - } - } - case "Metadata": - var zb0004 uint32 - zb0004, err = dc.ReadArrayHeader() - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - if cap(z.Metadata) >= int(zb0004) { - z.Metadata = (z.Metadata)[:zb0004] - } else { - z.Metadata = make([]BatchJobReplicateKV, zb0004) - } - for za0002 := range z.Metadata { - var zb0005 uint32 - zb0005, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - for zb0005 > 0 { - zb0005-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Metadata[za0002].Key, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Key") - return - } - case "Value": - z.Metadata[za0002].Value, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Value") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - } - } - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *BatchReplicateFilter) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 6 - // write "NewerThan" - err = en.Append(0x86, 0xa9, 0x4e, 0x65, 0x77, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) - if err != nil { - return - } - err = en.WriteDuration(z.NewerThan) - if err != nil { - err = msgp.WrapError(err, "NewerThan") - return - } - // write "OlderThan" - err = en.Append(0xa9, 0x4f, 0x6c, 0x64, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) - if err != nil { - return - } - err = en.WriteDuration(z.OlderThan) - if err != nil { - err = msgp.WrapError(err, "OlderThan") - return - } - // write "CreatedAfter" - err = en.Append(0xac, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72) - if err != nil { - return - } - err = en.WriteTime(z.CreatedAfter) - if err != nil { - err = msgp.WrapError(err, "CreatedAfter") - return - } - // write "CreatedBefore" - err = en.Append(0xad, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65) - if err != nil { - return - } - err = en.WriteTime(z.CreatedBefore) - if err != nil { - err = msgp.WrapError(err, "CreatedBefore") - return - } - // write "Tags" - err = en.Append(0xa4, 0x54, 0x61, 0x67, 0x73) - if err != nil { - return - } - err = en.WriteArrayHeader(uint32(len(z.Tags))) - if err != nil { - err = msgp.WrapError(err, "Tags") - return - } - for za0001 := range z.Tags { - // map header, size 2 - // write "Key" - err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Tags[za0001].Key) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Key") - return - } - // write "Value" - err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Tags[za0001].Value) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Value") - return - } - } - // write "Metadata" - err = en.Append(0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) - if err != nil { - return - } - err = en.WriteArrayHeader(uint32(len(z.Metadata))) - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - for za0002 := range z.Metadata { - // map header, size 2 - // write "Key" - err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Metadata[za0002].Key) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Key") - return - } - // write "Value" - err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Metadata[za0002].Value) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Value") - return - } - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *BatchReplicateFilter) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 6 - // string "NewerThan" - o = append(o, 0x86, 0xa9, 0x4e, 0x65, 0x77, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) - o = msgp.AppendDuration(o, z.NewerThan) - // string "OlderThan" - o = append(o, 0xa9, 0x4f, 0x6c, 0x64, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) - o = msgp.AppendDuration(o, z.OlderThan) - // string "CreatedAfter" - o = append(o, 0xac, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72) - o = msgp.AppendTime(o, z.CreatedAfter) - // string "CreatedBefore" - o = append(o, 0xad, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65) - o = msgp.AppendTime(o, z.CreatedBefore) - // string "Tags" - o = append(o, 0xa4, 0x54, 0x61, 0x67, 0x73) - o = msgp.AppendArrayHeader(o, uint32(len(z.Tags))) - for za0001 := range z.Tags { - // map header, size 2 - // string "Key" - o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Tags[za0001].Key) - // string "Value" - o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - o = msgp.AppendString(o, z.Tags[za0001].Value) - } - // string "Metadata" - o = append(o, 0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) - o = msgp.AppendArrayHeader(o, uint32(len(z.Metadata))) - for za0002 := range z.Metadata { - // map header, size 2 - // string "Key" - o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Metadata[za0002].Key) - // string "Value" - o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - o = msgp.AppendString(o, z.Metadata[za0002].Value) - } - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchReplicateFilter) 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 "NewerThan": - z.NewerThan, bts, err = msgp.ReadDurationBytes(bts) - if err != nil { - err = msgp.WrapError(err, "NewerThan") - return - } - case "OlderThan": - z.OlderThan, bts, err = msgp.ReadDurationBytes(bts) - if err != nil { - err = msgp.WrapError(err, "OlderThan") - return - } - case "CreatedAfter": - z.CreatedAfter, bts, err = msgp.ReadTimeBytes(bts) - if err != nil { - err = msgp.WrapError(err, "CreatedAfter") - return - } - case "CreatedBefore": - z.CreatedBefore, bts, err = msgp.ReadTimeBytes(bts) - if err != nil { - err = msgp.WrapError(err, "CreatedBefore") - return - } - case "Tags": - var zb0002 uint32 - zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Tags") - return - } - if cap(z.Tags) >= int(zb0002) { - z.Tags = (z.Tags)[:zb0002] - } else { - z.Tags = make([]BatchJobReplicateKV, zb0002) - } - for za0001 := range z.Tags { - var zb0003 uint32 - zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - for zb0003 > 0 { - zb0003-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Tags[za0001].Key, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Key") - return - } - case "Value": - z.Tags[za0001].Value, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Value") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - } - } - } - case "Metadata": - var zb0004 uint32 - zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata") - return - } - if cap(z.Metadata) >= int(zb0004) { - z.Metadata = (z.Metadata)[:zb0004] - } else { - z.Metadata = make([]BatchJobReplicateKV, zb0004) - } - for za0002 := range z.Metadata { - var zb0005 uint32 - zb0005, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - for zb0005 > 0 { - zb0005-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Metadata[za0002].Key, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Key") - return - } - case "Value": - z.Metadata[za0002].Value, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Value") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - 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 *BatchReplicateFilter) Msgsize() (s int) { - s = 1 + 10 + msgp.DurationSize + 10 + msgp.DurationSize + 13 + msgp.TimeSize + 14 + msgp.TimeSize + 5 + msgp.ArrayHeaderSize - for za0001 := range z.Tags { - s += 1 + 4 + msgp.StringPrefixSize + len(z.Tags[za0001].Key) + 6 + msgp.StringPrefixSize + len(z.Tags[za0001].Value) - } - s += 9 + msgp.ArrayHeaderSize - for za0002 := range z.Metadata { - s += 1 + 4 + msgp.StringPrefixSize + len(z.Metadata[za0002].Key) + 6 + msgp.StringPrefixSize + len(z.Metadata[za0002].Value) - } - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchReplicateNotification) 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 "Endpoint": - z.Endpoint, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - case "Token": - z.Token, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Token") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchReplicateNotification) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 2 - // write "Endpoint" - err = en.Append(0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - if err != nil { - return - } - err = en.WriteString(z.Endpoint) - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - // write "Token" - err = en.Append(0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.Token) - if err != nil { - err = msgp.WrapError(err, "Token") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchReplicateNotification) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 2 - // string "Endpoint" - o = append(o, 0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - o = msgp.AppendString(o, z.Endpoint) - // string "Token" - o = append(o, 0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - o = msgp.AppendString(o, z.Token) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchReplicateNotification) 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 "Endpoint": - z.Endpoint, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Endpoint") - return - } - case "Token": - z.Token, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Token") - 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 BatchReplicateNotification) Msgsize() (s int) { - s = 1 + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 6 + msgp.StringPrefixSize + len(z.Token) - return -} - -// DecodeMsg implements msgp.Decodable -func (z *BatchReplicateRetry) 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 "Attempts": - z.Attempts, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "Attempts") - return - } - case "Delay": - z.Delay, err = dc.ReadDuration() - if err != nil { - err = msgp.WrapError(err, "Delay") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchReplicateRetry) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 2 - // write "Attempts" - err = en.Append(0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - if err != nil { - return - } - err = en.WriteInt(z.Attempts) - if err != nil { - err = msgp.WrapError(err, "Attempts") - return - } - // write "Delay" - err = en.Append(0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - if err != nil { - return - } - err = en.WriteDuration(z.Delay) - if err != nil { - err = msgp.WrapError(err, "Delay") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchReplicateRetry) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 2 - // string "Attempts" - o = append(o, 0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - o = msgp.AppendInt(o, z.Attempts) - // string "Delay" - o = append(o, 0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - o = msgp.AppendDuration(o, z.Delay) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchReplicateRetry) 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 "Attempts": - z.Attempts, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Attempts") - return - } - case "Delay": - z.Delay, bts, err = msgp.ReadDurationBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Delay") - 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 BatchReplicateRetry) Msgsize() (s int) { - s = 1 + 9 + msgp.IntSize + 6 + msgp.DurationSize - return -} - // DecodeMsg implements msgp.Decodable func (z *batchJobInfo) DecodeMsg(dc *msgp.Reader) (err error) { var field []byte diff --git a/cmd/batch-handlers_gen_test.go b/cmd/batch-handlers_gen_test.go index d9f7dfe4e..64a04ca6f 100644 --- a/cmd/batch-handlers_gen_test.go +++ b/cmd/batch-handlers_gen_test.go @@ -9,684 +9,6 @@ import ( "github.com/tinylib/msgp/msgp" ) -func TestMarshalUnmarshalBatchJobReplicateCredentials(t *testing.T) { - v := BatchJobReplicateCredentials{} - 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 BenchmarkMarshalMsgBatchJobReplicateCredentials(b *testing.B) { - v := BatchJobReplicateCredentials{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchJobReplicateCredentials(b *testing.B) { - v := BatchJobReplicateCredentials{} - 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 BenchmarkUnmarshalBatchJobReplicateCredentials(b *testing.B) { - v := BatchJobReplicateCredentials{} - 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 TestEncodeDecodeBatchJobReplicateCredentials(t *testing.T) { - v := BatchJobReplicateCredentials{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchJobReplicateCredentials Msgsize() is inaccurate") - } - - vn := BatchJobReplicateCredentials{} - 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 BenchmarkEncodeBatchJobReplicateCredentials(b *testing.B) { - v := BatchJobReplicateCredentials{} - 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 BenchmarkDecodeBatchJobReplicateCredentials(b *testing.B) { - v := BatchJobReplicateCredentials{} - 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 TestMarshalUnmarshalBatchJobReplicateFlags(t *testing.T) { - v := BatchJobReplicateFlags{} - 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 BenchmarkMarshalMsgBatchJobReplicateFlags(b *testing.B) { - v := BatchJobReplicateFlags{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchJobReplicateFlags(b *testing.B) { - v := BatchJobReplicateFlags{} - 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 BenchmarkUnmarshalBatchJobReplicateFlags(b *testing.B) { - v := BatchJobReplicateFlags{} - 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 TestEncodeDecodeBatchJobReplicateFlags(t *testing.T) { - v := BatchJobReplicateFlags{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchJobReplicateFlags Msgsize() is inaccurate") - } - - vn := BatchJobReplicateFlags{} - 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 BenchmarkEncodeBatchJobReplicateFlags(b *testing.B) { - v := BatchJobReplicateFlags{} - 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 BenchmarkDecodeBatchJobReplicateFlags(b *testing.B) { - v := BatchJobReplicateFlags{} - 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 TestMarshalUnmarshalBatchJobReplicateKV(t *testing.T) { - v := BatchJobReplicateKV{} - 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 BenchmarkMarshalMsgBatchJobReplicateKV(b *testing.B) { - v := BatchJobReplicateKV{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchJobReplicateKV(b *testing.B) { - v := BatchJobReplicateKV{} - 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 BenchmarkUnmarshalBatchJobReplicateKV(b *testing.B) { - v := BatchJobReplicateKV{} - 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 TestEncodeDecodeBatchJobReplicateKV(t *testing.T) { - v := BatchJobReplicateKV{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchJobReplicateKV Msgsize() is inaccurate") - } - - vn := BatchJobReplicateKV{} - 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 BenchmarkEncodeBatchJobReplicateKV(b *testing.B) { - v := BatchJobReplicateKV{} - 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 BenchmarkDecodeBatchJobReplicateKV(b *testing.B) { - v := BatchJobReplicateKV{} - 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 TestMarshalUnmarshalBatchJobReplicateSource(t *testing.T) { - v := BatchJobReplicateSource{} - 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 BenchmarkMarshalMsgBatchJobReplicateSource(b *testing.B) { - v := BatchJobReplicateSource{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchJobReplicateSource(b *testing.B) { - v := BatchJobReplicateSource{} - 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 BenchmarkUnmarshalBatchJobReplicateSource(b *testing.B) { - v := BatchJobReplicateSource{} - 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 TestEncodeDecodeBatchJobReplicateSource(t *testing.T) { - v := BatchJobReplicateSource{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchJobReplicateSource Msgsize() is inaccurate") - } - - vn := BatchJobReplicateSource{} - 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 BenchmarkEncodeBatchJobReplicateSource(b *testing.B) { - v := BatchJobReplicateSource{} - 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 BenchmarkDecodeBatchJobReplicateSource(b *testing.B) { - v := BatchJobReplicateSource{} - 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 TestMarshalUnmarshalBatchJobReplicateTarget(t *testing.T) { - v := BatchJobReplicateTarget{} - 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 BenchmarkMarshalMsgBatchJobReplicateTarget(b *testing.B) { - v := BatchJobReplicateTarget{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchJobReplicateTarget(b *testing.B) { - v := BatchJobReplicateTarget{} - 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 BenchmarkUnmarshalBatchJobReplicateTarget(b *testing.B) { - v := BatchJobReplicateTarget{} - 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 TestEncodeDecodeBatchJobReplicateTarget(t *testing.T) { - v := BatchJobReplicateTarget{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchJobReplicateTarget Msgsize() is inaccurate") - } - - vn := BatchJobReplicateTarget{} - 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 BenchmarkEncodeBatchJobReplicateTarget(b *testing.B) { - v := BatchJobReplicateTarget{} - 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 BenchmarkDecodeBatchJobReplicateTarget(b *testing.B) { - v := BatchJobReplicateTarget{} - 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 TestMarshalUnmarshalBatchJobReplicateV1(t *testing.T) { - v := BatchJobReplicateV1{} - 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 BenchmarkMarshalMsgBatchJobReplicateV1(b *testing.B) { - v := BatchJobReplicateV1{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchJobReplicateV1(b *testing.B) { - v := BatchJobReplicateV1{} - 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 BenchmarkUnmarshalBatchJobReplicateV1(b *testing.B) { - v := BatchJobReplicateV1{} - 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 TestEncodeDecodeBatchJobReplicateV1(t *testing.T) { - v := BatchJobReplicateV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchJobReplicateV1 Msgsize() is inaccurate") - } - - vn := BatchJobReplicateV1{} - 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 BenchmarkEncodeBatchJobReplicateV1(b *testing.B) { - v := BatchJobReplicateV1{} - 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 BenchmarkDecodeBatchJobReplicateV1(b *testing.B) { - v := BatchJobReplicateV1{} - 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 TestMarshalUnmarshalBatchJobRequest(t *testing.T) { v := BatchJobRequest{} bts, err := v.MarshalMsg(nil) @@ -800,345 +122,6 @@ func BenchmarkDecodeBatchJobRequest(b *testing.B) { } } -func TestMarshalUnmarshalBatchReplicateFilter(t *testing.T) { - v := BatchReplicateFilter{} - 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 BenchmarkMarshalMsgBatchReplicateFilter(b *testing.B) { - v := BatchReplicateFilter{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchReplicateFilter(b *testing.B) { - v := BatchReplicateFilter{} - 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 BenchmarkUnmarshalBatchReplicateFilter(b *testing.B) { - v := BatchReplicateFilter{} - 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 TestEncodeDecodeBatchReplicateFilter(t *testing.T) { - v := BatchReplicateFilter{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchReplicateFilter Msgsize() is inaccurate") - } - - vn := BatchReplicateFilter{} - 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 BenchmarkEncodeBatchReplicateFilter(b *testing.B) { - v := BatchReplicateFilter{} - 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 BenchmarkDecodeBatchReplicateFilter(b *testing.B) { - v := BatchReplicateFilter{} - 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 TestMarshalUnmarshalBatchReplicateNotification(t *testing.T) { - v := BatchReplicateNotification{} - 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 BenchmarkMarshalMsgBatchReplicateNotification(b *testing.B) { - v := BatchReplicateNotification{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchReplicateNotification(b *testing.B) { - v := BatchReplicateNotification{} - 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 BenchmarkUnmarshalBatchReplicateNotification(b *testing.B) { - v := BatchReplicateNotification{} - 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 TestEncodeDecodeBatchReplicateNotification(t *testing.T) { - v := BatchReplicateNotification{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchReplicateNotification Msgsize() is inaccurate") - } - - vn := BatchReplicateNotification{} - 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 BenchmarkEncodeBatchReplicateNotification(b *testing.B) { - v := BatchReplicateNotification{} - 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 BenchmarkDecodeBatchReplicateNotification(b *testing.B) { - v := BatchReplicateNotification{} - 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 TestMarshalUnmarshalBatchReplicateRetry(t *testing.T) { - v := BatchReplicateRetry{} - 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 BenchmarkMarshalMsgBatchReplicateRetry(b *testing.B) { - v := BatchReplicateRetry{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchReplicateRetry(b *testing.B) { - v := BatchReplicateRetry{} - 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 BenchmarkUnmarshalBatchReplicateRetry(b *testing.B) { - v := BatchReplicateRetry{} - 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 TestEncodeDecodeBatchReplicateRetry(t *testing.T) { - v := BatchReplicateRetry{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchReplicateRetry Msgsize() is inaccurate") - } - - vn := BatchReplicateRetry{} - 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 BenchmarkEncodeBatchReplicateRetry(b *testing.B) { - v := BatchReplicateRetry{} - 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 BenchmarkDecodeBatchReplicateRetry(b *testing.B) { - v := BatchReplicateRetry{} - 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 TestMarshalUnmarshalbatchJobInfo(t *testing.T) { v := batchJobInfo{} bts, err := v.MarshalMsg(nil) diff --git a/cmd/batch-job-common-types.go b/cmd/batch-job-common-types.go new file mode 100644 index 000000000..a98d3e4e8 --- /dev/null +++ b/cmd/batch-job-common-types.go @@ -0,0 +1,83 @@ +// 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 cmd + +import ( + "strings" + "time" + + "github.com/minio/pkg/wildcard" +) + +//go:generate msgp -file $GOFILE + +// BatchJobKV is a key-value data type which supports wildcard matching +type BatchJobKV struct { + Key string `yaml:"key" json:"key"` + Value string `yaml:"value" json:"value"` +} + +// Validate returns an error if key is empty +func (kv BatchJobKV) Validate() error { + if kv.Key == "" { + return errInvalidArgument + } + return nil +} + +// Empty indicates if kv is not set +func (kv BatchJobKV) Empty() bool { + return kv.Key == "" && kv.Value == "" +} + +// Match matches input kv with kv, value will be wildcard matched depending on the user input +func (kv BatchJobKV) Match(ikv BatchJobKV) bool { + if kv.Empty() { + return true + } + if strings.EqualFold(kv.Key, ikv.Key) { + return wildcard.Match(kv.Value, ikv.Value) + } + return false +} + +// BatchJobNotification stores notification endpoint and token information. +// Used by batch jobs to notify of their status. +type BatchJobNotification struct { + Endpoint string `yaml:"endpoint" json:"endpoint"` + Token string `yaml:"token" json:"token"` +} + +// BatchJobRetry stores retry configuration used in the event of failures. +type BatchJobRetry struct { + Attempts int `yaml:"attempts" json:"attempts"` // number of retry attempts + Delay time.Duration `yaml:"delay" json:"delay"` // delay between each retries +} + +// Validate validates input replicate retries. +func (r BatchJobRetry) Validate() error { + if r.Attempts < 0 { + return errInvalidArgument + } + + if r.Delay < 0 { + return errInvalidArgument + } + + return nil +} diff --git a/cmd/batch-job-common-types_gen.go b/cmd/batch-job-common-types_gen.go new file mode 100644 index 000000000..ca3fb48c6 --- /dev/null +++ b/cmd/batch-job-common-types_gen.go @@ -0,0 +1,391 @@ +package cmd + +// Code generated by github.com/tinylib/msgp DO NOT EDIT. + +import ( + "github.com/tinylib/msgp/msgp" +) + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobKV) 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 "Value": + z.Value, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Value") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z BatchJobKV) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 2 + // write "Key" + err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.Key) + if err != nil { + err = msgp.WrapError(err, "Key") + return + } + // write "Value" + err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) + if err != nil { + return + } + err = en.WriteString(z.Value) + if err != nil { + err = msgp.WrapError(err, "Value") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z BatchJobKV) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 2 + // string "Key" + o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.Key) + // string "Value" + o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) + o = msgp.AppendString(o, z.Value) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobKV) 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 "Value": + z.Value, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Value") + 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 BatchJobKV) Msgsize() (s int) { + s = 1 + 4 + msgp.StringPrefixSize + len(z.Key) + 6 + msgp.StringPrefixSize + len(z.Value) + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobNotification) 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 "Endpoint": + z.Endpoint, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + case "Token": + z.Token, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Token") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z BatchJobNotification) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 2 + // write "Endpoint" + err = en.Append(0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + if err != nil { + return + } + err = en.WriteString(z.Endpoint) + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + // write "Token" + err = en.Append(0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + if err != nil { + return + } + err = en.WriteString(z.Token) + if err != nil { + err = msgp.WrapError(err, "Token") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z BatchJobNotification) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 2 + // string "Endpoint" + o = append(o, 0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + o = msgp.AppendString(o, z.Endpoint) + // string "Token" + o = append(o, 0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + o = msgp.AppendString(o, z.Token) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobNotification) 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 "Endpoint": + z.Endpoint, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + case "Token": + z.Token, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Token") + 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 BatchJobNotification) Msgsize() (s int) { + s = 1 + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 6 + msgp.StringPrefixSize + len(z.Token) + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobRetry) 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 "Attempts": + z.Attempts, err = dc.ReadInt() + if err != nil { + err = msgp.WrapError(err, "Attempts") + return + } + case "Delay": + z.Delay, err = dc.ReadDuration() + if err != nil { + err = msgp.WrapError(err, "Delay") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z BatchJobRetry) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 2 + // write "Attempts" + err = en.Append(0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) + if err != nil { + return + } + err = en.WriteInt(z.Attempts) + if err != nil { + err = msgp.WrapError(err, "Attempts") + return + } + // write "Delay" + err = en.Append(0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) + if err != nil { + return + } + err = en.WriteDuration(z.Delay) + if err != nil { + err = msgp.WrapError(err, "Delay") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z BatchJobRetry) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 2 + // string "Attempts" + o = append(o, 0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) + o = msgp.AppendInt(o, z.Attempts) + // string "Delay" + o = append(o, 0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) + o = msgp.AppendDuration(o, z.Delay) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobRetry) 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 "Attempts": + z.Attempts, bts, err = msgp.ReadIntBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Attempts") + return + } + case "Delay": + z.Delay, bts, err = msgp.ReadDurationBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Delay") + 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 BatchJobRetry) Msgsize() (s int) { + s = 1 + 9 + msgp.IntSize + 6 + msgp.DurationSize + return +} diff --git a/cmd/batch-job-common-types_gen_test.go b/cmd/batch-job-common-types_gen_test.go new file mode 100644 index 000000000..6c50a7708 --- /dev/null +++ b/cmd/batch-job-common-types_gen_test.go @@ -0,0 +1,349 @@ +package cmd + +// Code generated by github.com/tinylib/msgp DO NOT EDIT. + +import ( + "bytes" + "testing" + + "github.com/tinylib/msgp/msgp" +) + +func TestMarshalUnmarshalBatchJobKV(t *testing.T) { + v := BatchJobKV{} + 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 BenchmarkMarshalMsgBatchJobKV(b *testing.B) { + v := BatchJobKV{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobKV(b *testing.B) { + v := BatchJobKV{} + 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 BenchmarkUnmarshalBatchJobKV(b *testing.B) { + v := BatchJobKV{} + 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 TestEncodeDecodeBatchJobKV(t *testing.T) { + v := BatchJobKV{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobKV Msgsize() is inaccurate") + } + + vn := BatchJobKV{} + 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 BenchmarkEncodeBatchJobKV(b *testing.B) { + v := BatchJobKV{} + 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 BenchmarkDecodeBatchJobKV(b *testing.B) { + v := BatchJobKV{} + 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 TestMarshalUnmarshalBatchJobNotification(t *testing.T) { + v := BatchJobNotification{} + 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 BenchmarkMarshalMsgBatchJobNotification(b *testing.B) { + v := BatchJobNotification{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobNotification(b *testing.B) { + v := BatchJobNotification{} + 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 BenchmarkUnmarshalBatchJobNotification(b *testing.B) { + v := BatchJobNotification{} + 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 TestEncodeDecodeBatchJobNotification(t *testing.T) { + v := BatchJobNotification{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobNotification Msgsize() is inaccurate") + } + + vn := BatchJobNotification{} + 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 BenchmarkEncodeBatchJobNotification(b *testing.B) { + v := BatchJobNotification{} + 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 BenchmarkDecodeBatchJobNotification(b *testing.B) { + v := BatchJobNotification{} + 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 TestMarshalUnmarshalBatchJobRetry(t *testing.T) { + v := BatchJobRetry{} + 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 BenchmarkMarshalMsgBatchJobRetry(b *testing.B) { + v := BatchJobRetry{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobRetry(b *testing.B) { + v := BatchJobRetry{} + 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 BenchmarkUnmarshalBatchJobRetry(b *testing.B) { + v := BatchJobRetry{} + 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 TestEncodeDecodeBatchJobRetry(t *testing.T) { + v := BatchJobRetry{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobRetry Msgsize() is inaccurate") + } + + vn := BatchJobRetry{} + 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 BenchmarkEncodeBatchJobRetry(b *testing.B) { + v := BatchJobRetry{} + 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 BenchmarkDecodeBatchJobRetry(b *testing.B) { + v := BatchJobRetry{} + 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/cmd/batch-replicate.go b/cmd/batch-replicate.go new file mode 100644 index 000000000..3728096a4 --- /dev/null +++ b/cmd/batch-replicate.go @@ -0,0 +1,183 @@ +// 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 cmd + +import ( + "time" + + miniogo "github.com/minio/minio-go/v7" + + "github.com/minio/minio/internal/auth" +) + +//go:generate msgp -file $GOFILE + +// replicate: +// # source of the objects to be replicated +// source: +// type: "minio" +// bucket: "testbucket" +// prefix: "spark/" +// +// # optional flags based filtering criteria +// # for source objects +// flags: +// filter: +// newerThan: "7d" +// olderThan: "7d" +// createdAfter: "date" +// createdBefore: "date" +// tags: +// - key: "name" +// value: "value*" +// metadata: +// - key: "content-type" +// value: "image/*" +// notify: +// endpoint: "https://splunk-hec.dev.com" +// token: "Splunk ..." # e.g. "Bearer token" +// +// # target where the objects must be replicated +// target: +// type: "minio" +// bucket: "testbucket1" +// endpoint: "https://play.min.io" +// path: "on" +// credentials: +// accessKey: "minioadmin" +// secretKey: "minioadmin" +// sessionToken: "" + +// BatchReplicateFilter holds all the filters currently supported for batch replication +type BatchReplicateFilter struct { + NewerThan time.Duration `yaml:"newerThan,omitempty" json:"newerThan"` + OlderThan time.Duration `yaml:"olderThan,omitempty" json:"olderThan"` + CreatedAfter time.Time `yaml:"createdAfter,omitempty" json:"createdAfter"` + CreatedBefore time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` + Tags []BatchJobKV `yaml:"tags,omitempty" json:"tags"` + Metadata []BatchJobKV `yaml:"metadata,omitempty" json:"metadata"` +} + +// BatchJobReplicateFlags various configurations for replication job definition currently includes +// - filter +// - notify +// - retry +type BatchJobReplicateFlags struct { + Filter BatchReplicateFilter `yaml:"filter" json:"filter"` + Notify BatchJobNotification `yaml:"notify" json:"notify"` + Retry BatchJobRetry `yaml:"retry" json:"retry"` +} + +// BatchJobReplicateResourceType defines the type of batch jobs +type BatchJobReplicateResourceType string + +// Validate validates if the replicate resource type is recognized and supported +func (t BatchJobReplicateResourceType) Validate() error { + switch t { + case BatchJobReplicateResourceMinIO: + case BatchJobReplicateResourceS3: + default: + return errInvalidArgument + } + return nil +} + +func (t BatchJobReplicateResourceType) isMinio() bool { + return t == BatchJobReplicateResourceMinIO +} + +// Different types of batch jobs.. +const ( + BatchJobReplicateResourceMinIO BatchJobReplicateResourceType = "minio" + BatchJobReplicateResourceS3 BatchJobReplicateResourceType = "s3" + + // add future targets +) + +// BatchJobReplicateCredentials access credentials for batch replication it may +// be either for target or source. +type BatchJobReplicateCredentials struct { + AccessKey string `xml:"AccessKeyId" json:"accessKey,omitempty" yaml:"accessKey"` + SecretKey string `xml:"SecretAccessKey" json:"secretKey,omitempty" yaml:"secretKey"` + SessionToken string `xml:"SessionToken" json:"sessionToken,omitempty" yaml:"sessionToken"` +} + +// Empty indicates if credentials are not set +func (c BatchJobReplicateCredentials) Empty() bool { + return c.AccessKey == "" && c.SecretKey == "" && c.SessionToken == "" +} + +// Validate validates if credentials are valid +func (c BatchJobReplicateCredentials) Validate() error { + if !auth.IsAccessKeyValid(c.AccessKey) || !auth.IsSecretKeyValid(c.SecretKey) { + return errInvalidArgument + } + return nil +} + +// BatchJobReplicateTarget describes target element of the replication job that receives +// the filtered data from source +type BatchJobReplicateTarget struct { + Type BatchJobReplicateResourceType `yaml:"type" json:"type"` + Bucket string `yaml:"bucket" json:"bucket"` + Prefix string `yaml:"prefix" json:"prefix"` + Endpoint string `yaml:"endpoint" json:"endpoint"` + Path string `yaml:"path" json:"path"` + Creds BatchJobReplicateCredentials `yaml:"credentials" json:"credentials"` +} + +// ValidPath returns true if path is valid +func (t BatchJobReplicateTarget) ValidPath() bool { + return t.Path == "on" || t.Path == "off" || t.Path == "auto" || t.Path == "" +} + +// BatchJobReplicateSource describes source element of the replication job that is +// the source of the data for the target +type BatchJobReplicateSource struct { + Type BatchJobReplicateResourceType `yaml:"type" json:"type"` + Bucket string `yaml:"bucket" json:"bucket"` + Prefix string `yaml:"prefix" json:"prefix"` + Endpoint string `yaml:"endpoint" json:"endpoint"` + Path string `yaml:"path" json:"path"` + Creds BatchJobReplicateCredentials `yaml:"credentials" json:"credentials"` +} + +// ValidPath returns true if path is valid +func (s BatchJobReplicateSource) ValidPath() bool { + switch s.Path { + case "on", "off", "auto", "": + return true + default: + return false + } +} + +// BatchJobReplicateV1 v1 of batch job replication +type BatchJobReplicateV1 struct { + APIVersion string `yaml:"apiVersion" json:"apiVersion"` + Flags BatchJobReplicateFlags `yaml:"flags" json:"flags"` + Target BatchJobReplicateTarget `yaml:"target" json:"target"` + Source BatchJobReplicateSource `yaml:"source" json:"source"` + + clnt *miniogo.Core `msg:"-"` +} + +// RemoteToLocal returns true if source is remote and target is local +func (r BatchJobReplicateV1) RemoteToLocal() bool { + return !r.Source.Creds.Empty() +} diff --git a/cmd/batch-replicate_gen.go b/cmd/batch-replicate_gen.go new file mode 100644 index 000000000..d6be8d555 --- /dev/null +++ b/cmd/batch-replicate_gen.go @@ -0,0 +1,1677 @@ +package cmd + +// Code generated by github.com/tinylib/msgp DO NOT EDIT. + +import ( + "github.com/tinylib/msgp/msgp" +) + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobReplicateCredentials) 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 "AccessKey": + z.AccessKey, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "AccessKey") + return + } + case "SecretKey": + z.SecretKey, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "SecretKey") + return + } + case "SessionToken": + z.SessionToken, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "SessionToken") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z BatchJobReplicateCredentials) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 3 + // write "AccessKey" + err = en.Append(0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.AccessKey) + if err != nil { + err = msgp.WrapError(err, "AccessKey") + return + } + // write "SecretKey" + err = en.Append(0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.SecretKey) + if err != nil { + err = msgp.WrapError(err, "SecretKey") + return + } + // write "SessionToken" + err = en.Append(0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + if err != nil { + return + } + err = en.WriteString(z.SessionToken) + if err != nil { + err = msgp.WrapError(err, "SessionToken") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z BatchJobReplicateCredentials) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 3 + // string "AccessKey" + o = append(o, 0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.AccessKey) + // string "SecretKey" + o = append(o, 0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.SecretKey) + // string "SessionToken" + o = append(o, 0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + o = msgp.AppendString(o, z.SessionToken) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobReplicateCredentials) 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 "AccessKey": + z.AccessKey, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "AccessKey") + return + } + case "SecretKey": + z.SecretKey, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SecretKey") + return + } + case "SessionToken": + z.SessionToken, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SessionToken") + 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 BatchJobReplicateCredentials) Msgsize() (s int) { + s = 1 + 10 + msgp.StringPrefixSize + len(z.AccessKey) + 10 + msgp.StringPrefixSize + len(z.SecretKey) + 13 + msgp.StringPrefixSize + len(z.SessionToken) + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobReplicateFlags) 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 "Filter": + err = z.Filter.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Filter") + return + } + case "Notify": + err = z.Notify.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Notify") + return + } + case "Retry": + err = z.Retry.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Retry") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z *BatchJobReplicateFlags) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 3 + // write "Filter" + err = en.Append(0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) + if err != nil { + return + } + err = z.Filter.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Filter") + return + } + // write "Notify" + err = en.Append(0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) + if err != nil { + return + } + err = z.Notify.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Notify") + return + } + // write "Retry" + err = en.Append(0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) + if err != nil { + return + } + err = z.Retry.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Retry") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z *BatchJobReplicateFlags) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 3 + // string "Filter" + o = append(o, 0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) + o, err = z.Filter.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Filter") + return + } + // string "Notify" + o = append(o, 0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) + o, err = z.Notify.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Notify") + return + } + // string "Retry" + o = append(o, 0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) + o, err = z.Retry.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Retry") + return + } + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobReplicateFlags) 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 "Filter": + bts, err = z.Filter.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Filter") + return + } + case "Notify": + bts, err = z.Notify.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Notify") + return + } + case "Retry": + bts, err = z.Retry.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Retry") + 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 *BatchJobReplicateFlags) Msgsize() (s int) { + s = 1 + 7 + z.Filter.Msgsize() + 7 + z.Notify.Msgsize() + 6 + z.Retry.Msgsize() + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobReplicateResourceType) DecodeMsg(dc *msgp.Reader) (err error) { + { + var zb0001 string + zb0001, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = BatchJobReplicateResourceType(zb0001) + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z BatchJobReplicateResourceType) EncodeMsg(en *msgp.Writer) (err error) { + err = en.WriteString(string(z)) + if err != nil { + err = msgp.WrapError(err) + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z BatchJobReplicateResourceType) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobReplicateResourceType) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = BatchJobReplicateResourceType(zb0001) + } + o = bts + return +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z BatchJobReplicateResourceType) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobReplicateSource) 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 "Type": + { + var zb0002 string + zb0002, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + z.Type = BatchJobReplicateResourceType(zb0002) + } + case "Bucket": + z.Bucket, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Bucket") + return + } + case "Prefix": + z.Prefix, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Prefix") + return + } + case "Endpoint": + z.Endpoint, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + case "Path": + z.Path, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Path") + return + } + case "Creds": + var zb0003 uint32 + zb0003, err = dc.ReadMapHeader() + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + for zb0003 > 0 { + zb0003-- + field, err = dc.ReadMapKeyPtr() + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + switch msgp.UnsafeString(field) { + case "AccessKey": + z.Creds.AccessKey, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Creds", "AccessKey") + return + } + case "SecretKey": + z.Creds.SecretKey, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Creds", "SecretKey") + return + } + case "SessionToken": + z.Creds.SessionToken, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Creds", "SessionToken") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + } + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z *BatchJobReplicateSource) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 6 + // write "Type" + err = en.Append(0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) + if err != nil { + return + } + err = en.WriteString(string(z.Type)) + if err != nil { + err = msgp.WrapError(err, "Type") + 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 "Prefix" + err = en.Append(0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) + if err != nil { + return + } + err = en.WriteString(z.Prefix) + if err != nil { + err = msgp.WrapError(err, "Prefix") + return + } + // write "Endpoint" + err = en.Append(0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + if err != nil { + return + } + err = en.WriteString(z.Endpoint) + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + // write "Path" + err = en.Append(0xa4, 0x50, 0x61, 0x74, 0x68) + if err != nil { + return + } + err = en.WriteString(z.Path) + if err != nil { + err = msgp.WrapError(err, "Path") + return + } + // write "Creds" + err = en.Append(0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) + if err != nil { + return + } + // map header, size 3 + // write "AccessKey" + err = en.Append(0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.Creds.AccessKey) + if err != nil { + err = msgp.WrapError(err, "Creds", "AccessKey") + return + } + // write "SecretKey" + err = en.Append(0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.Creds.SecretKey) + if err != nil { + err = msgp.WrapError(err, "Creds", "SecretKey") + return + } + // write "SessionToken" + err = en.Append(0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + if err != nil { + return + } + err = en.WriteString(z.Creds.SessionToken) + if err != nil { + err = msgp.WrapError(err, "Creds", "SessionToken") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z *BatchJobReplicateSource) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 6 + // string "Type" + o = append(o, 0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) + o = msgp.AppendString(o, string(z.Type)) + // string "Bucket" + o = append(o, 0xa6, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74) + o = msgp.AppendString(o, z.Bucket) + // string "Prefix" + o = append(o, 0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) + o = msgp.AppendString(o, z.Prefix) + // string "Endpoint" + o = append(o, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + o = msgp.AppendString(o, z.Endpoint) + // string "Path" + o = append(o, 0xa4, 0x50, 0x61, 0x74, 0x68) + o = msgp.AppendString(o, z.Path) + // string "Creds" + o = append(o, 0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) + // map header, size 3 + // string "AccessKey" + o = append(o, 0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.Creds.AccessKey) + // string "SecretKey" + o = append(o, 0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.Creds.SecretKey) + // string "SessionToken" + o = append(o, 0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + o = msgp.AppendString(o, z.Creds.SessionToken) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobReplicateSource) 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 "Type": + { + var zb0002 string + zb0002, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + z.Type = BatchJobReplicateResourceType(zb0002) + } + case "Bucket": + z.Bucket, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Bucket") + return + } + case "Prefix": + z.Prefix, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Prefix") + return + } + case "Endpoint": + z.Endpoint, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + case "Path": + z.Path, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Path") + return + } + case "Creds": + var zb0003 uint32 + zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + switch msgp.UnsafeString(field) { + case "AccessKey": + z.Creds.AccessKey, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds", "AccessKey") + return + } + case "SecretKey": + z.Creds.SecretKey, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds", "SecretKey") + return + } + case "SessionToken": + z.Creds.SessionToken, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds", "SessionToken") + return + } + default: + bts, err = msgp.Skip(bts) + if err != nil { + err = msgp.WrapError(err, "Creds") + 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 *BatchJobReplicateSource) Msgsize() (s int) { + s = 1 + 5 + msgp.StringPrefixSize + len(string(z.Type)) + 7 + msgp.StringPrefixSize + len(z.Bucket) + 7 + msgp.StringPrefixSize + len(z.Prefix) + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 5 + msgp.StringPrefixSize + len(z.Path) + 6 + 1 + 10 + msgp.StringPrefixSize + len(z.Creds.AccessKey) + 10 + msgp.StringPrefixSize + len(z.Creds.SecretKey) + 13 + msgp.StringPrefixSize + len(z.Creds.SessionToken) + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobReplicateTarget) 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 "Type": + { + var zb0002 string + zb0002, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + z.Type = BatchJobReplicateResourceType(zb0002) + } + case "Bucket": + z.Bucket, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Bucket") + return + } + case "Prefix": + z.Prefix, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Prefix") + return + } + case "Endpoint": + z.Endpoint, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + case "Path": + z.Path, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Path") + return + } + case "Creds": + var zb0003 uint32 + zb0003, err = dc.ReadMapHeader() + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + for zb0003 > 0 { + zb0003-- + field, err = dc.ReadMapKeyPtr() + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + switch msgp.UnsafeString(field) { + case "AccessKey": + z.Creds.AccessKey, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Creds", "AccessKey") + return + } + case "SecretKey": + z.Creds.SecretKey, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Creds", "SecretKey") + return + } + case "SessionToken": + z.Creds.SessionToken, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "Creds", "SessionToken") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + } + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z *BatchJobReplicateTarget) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 6 + // write "Type" + err = en.Append(0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) + if err != nil { + return + } + err = en.WriteString(string(z.Type)) + if err != nil { + err = msgp.WrapError(err, "Type") + 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 "Prefix" + err = en.Append(0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) + if err != nil { + return + } + err = en.WriteString(z.Prefix) + if err != nil { + err = msgp.WrapError(err, "Prefix") + return + } + // write "Endpoint" + err = en.Append(0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + if err != nil { + return + } + err = en.WriteString(z.Endpoint) + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + // write "Path" + err = en.Append(0xa4, 0x50, 0x61, 0x74, 0x68) + if err != nil { + return + } + err = en.WriteString(z.Path) + if err != nil { + err = msgp.WrapError(err, "Path") + return + } + // write "Creds" + err = en.Append(0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) + if err != nil { + return + } + // map header, size 3 + // write "AccessKey" + err = en.Append(0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.Creds.AccessKey) + if err != nil { + err = msgp.WrapError(err, "Creds", "AccessKey") + return + } + // write "SecretKey" + err = en.Append(0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) + if err != nil { + return + } + err = en.WriteString(z.Creds.SecretKey) + if err != nil { + err = msgp.WrapError(err, "Creds", "SecretKey") + return + } + // write "SessionToken" + err = en.Append(0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + if err != nil { + return + } + err = en.WriteString(z.Creds.SessionToken) + if err != nil { + err = msgp.WrapError(err, "Creds", "SessionToken") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z *BatchJobReplicateTarget) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 6 + // string "Type" + o = append(o, 0x86, 0xa4, 0x54, 0x79, 0x70, 0x65) + o = msgp.AppendString(o, string(z.Type)) + // string "Bucket" + o = append(o, 0xa6, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74) + o = msgp.AppendString(o, z.Bucket) + // string "Prefix" + o = append(o, 0xa6, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78) + o = msgp.AppendString(o, z.Prefix) + // string "Endpoint" + o = append(o, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + o = msgp.AppendString(o, z.Endpoint) + // string "Path" + o = append(o, 0xa4, 0x50, 0x61, 0x74, 0x68) + o = msgp.AppendString(o, z.Path) + // string "Creds" + o = append(o, 0xa5, 0x43, 0x72, 0x65, 0x64, 0x73) + // map header, size 3 + // string "AccessKey" + o = append(o, 0x83, 0xa9, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.Creds.AccessKey) + // string "SecretKey" + o = append(o, 0xa9, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79) + o = msgp.AppendString(o, z.Creds.SecretKey) + // string "SessionToken" + o = append(o, 0xac, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e) + o = msgp.AppendString(o, z.Creds.SessionToken) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobReplicateTarget) 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 "Type": + { + var zb0002 string + zb0002, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + z.Type = BatchJobReplicateResourceType(zb0002) + } + case "Bucket": + z.Bucket, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Bucket") + return + } + case "Prefix": + z.Prefix, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Prefix") + return + } + case "Endpoint": + z.Endpoint, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Endpoint") + return + } + case "Path": + z.Path, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Path") + return + } + case "Creds": + var zb0003 uint32 + zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "Creds") + return + } + switch msgp.UnsafeString(field) { + case "AccessKey": + z.Creds.AccessKey, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds", "AccessKey") + return + } + case "SecretKey": + z.Creds.SecretKey, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds", "SecretKey") + return + } + case "SessionToken": + z.Creds.SessionToken, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Creds", "SessionToken") + return + } + default: + bts, err = msgp.Skip(bts) + if err != nil { + err = msgp.WrapError(err, "Creds") + 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 *BatchJobReplicateTarget) Msgsize() (s int) { + s = 1 + 5 + msgp.StringPrefixSize + len(string(z.Type)) + 7 + msgp.StringPrefixSize + len(z.Bucket) + 7 + msgp.StringPrefixSize + len(z.Prefix) + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 5 + msgp.StringPrefixSize + len(z.Path) + 6 + 1 + 10 + msgp.StringPrefixSize + len(z.Creds.AccessKey) + 10 + msgp.StringPrefixSize + len(z.Creds.SecretKey) + 13 + msgp.StringPrefixSize + len(z.Creds.SessionToken) + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchJobReplicateV1) 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 "APIVersion": + z.APIVersion, err = dc.ReadString() + if err != nil { + err = msgp.WrapError(err, "APIVersion") + return + } + case "Flags": + var zb0002 uint32 + zb0002, err = dc.ReadMapHeader() + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + for zb0002 > 0 { + zb0002-- + field, err = dc.ReadMapKeyPtr() + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + switch msgp.UnsafeString(field) { + case "Filter": + err = z.Flags.Filter.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + case "Notify": + err = z.Flags.Notify.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + case "Retry": + err = z.Flags.Retry.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + } + } + case "Target": + err = z.Target.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Target") + return + } + case "Source": + err = z.Source.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Source") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z *BatchJobReplicateV1) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 4 + // write "APIVersion" + err = en.Append(0x84, 0xaa, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e) + if err != nil { + return + } + err = en.WriteString(z.APIVersion) + if err != nil { + err = msgp.WrapError(err, "APIVersion") + return + } + // write "Flags" + err = en.Append(0xa5, 0x46, 0x6c, 0x61, 0x67, 0x73) + if err != nil { + return + } + // map header, size 3 + // write "Filter" + err = en.Append(0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) + if err != nil { + return + } + err = z.Flags.Filter.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + // write "Notify" + err = en.Append(0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) + if err != nil { + return + } + err = z.Flags.Notify.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + // write "Retry" + err = en.Append(0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) + if err != nil { + return + } + err = z.Flags.Retry.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") + return + } + // write "Target" + err = en.Append(0xa6, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74) + if err != nil { + return + } + err = z.Target.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Target") + return + } + // write "Source" + err = en.Append(0xa6, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65) + if err != nil { + return + } + err = z.Source.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Source") + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z *BatchJobReplicateV1) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 4 + // string "APIVersion" + o = append(o, 0x84, 0xaa, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e) + o = msgp.AppendString(o, z.APIVersion) + // string "Flags" + o = append(o, 0xa5, 0x46, 0x6c, 0x61, 0x67, 0x73) + // map header, size 3 + // string "Filter" + o = append(o, 0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) + o, err = z.Flags.Filter.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + // string "Notify" + o = append(o, 0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) + o, err = z.Flags.Notify.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + // string "Retry" + o = append(o, 0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) + o, err = z.Flags.Retry.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") + return + } + // string "Target" + o = append(o, 0xa6, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74) + o, err = z.Target.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Target") + return + } + // string "Source" + o = append(o, 0xa6, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65) + o, err = z.Source.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Source") + return + } + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchJobReplicateV1) 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 "APIVersion": + z.APIVersion, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "APIVersion") + return + } + case "Flags": + var zb0002 uint32 + zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + switch msgp.UnsafeString(field) { + case "Filter": + bts, err = z.Flags.Filter.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + case "Notify": + bts, err = z.Flags.Notify.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + case "Retry": + bts, err = z.Flags.Retry.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") + return + } + default: + bts, err = msgp.Skip(bts) + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + } + } + case "Target": + bts, err = z.Target.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Target") + return + } + case "Source": + bts, err = z.Source.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Source") + 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 *BatchJobReplicateV1) Msgsize() (s int) { + s = 1 + 11 + msgp.StringPrefixSize + len(z.APIVersion) + 6 + 1 + 7 + z.Flags.Filter.Msgsize() + 7 + z.Flags.Notify.Msgsize() + 6 + z.Flags.Retry.Msgsize() + 7 + z.Target.Msgsize() + 7 + z.Source.Msgsize() + return +} + +// DecodeMsg implements msgp.Decodable +func (z *BatchReplicateFilter) 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 "NewerThan": + z.NewerThan, err = dc.ReadDuration() + if err != nil { + err = msgp.WrapError(err, "NewerThan") + return + } + case "OlderThan": + z.OlderThan, err = dc.ReadDuration() + if err != nil { + err = msgp.WrapError(err, "OlderThan") + return + } + case "CreatedAfter": + z.CreatedAfter, err = dc.ReadTime() + if err != nil { + err = msgp.WrapError(err, "CreatedAfter") + return + } + case "CreatedBefore": + z.CreatedBefore, err = dc.ReadTime() + if err != nil { + err = msgp.WrapError(err, "CreatedBefore") + return + } + case "Tags": + var zb0002 uint32 + zb0002, err = dc.ReadArrayHeader() + if err != nil { + err = msgp.WrapError(err, "Tags") + return + } + if cap(z.Tags) >= int(zb0002) { + z.Tags = (z.Tags)[:zb0002] + } else { + z.Tags = make([]BatchJobKV, zb0002) + } + for za0001 := range z.Tags { + err = z.Tags[za0001].DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Tags", za0001) + return + } + } + case "Metadata": + var zb0003 uint32 + zb0003, err = dc.ReadArrayHeader() + if err != nil { + err = msgp.WrapError(err, "Metadata") + return + } + if cap(z.Metadata) >= int(zb0003) { + z.Metadata = (z.Metadata)[:zb0003] + } else { + z.Metadata = make([]BatchJobKV, zb0003) + } + for za0002 := range z.Metadata { + err = z.Metadata[za0002].DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Metadata", za0002) + return + } + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z *BatchReplicateFilter) EncodeMsg(en *msgp.Writer) (err error) { + // map header, size 6 + // write "NewerThan" + err = en.Append(0x86, 0xa9, 0x4e, 0x65, 0x77, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) + if err != nil { + return + } + err = en.WriteDuration(z.NewerThan) + if err != nil { + err = msgp.WrapError(err, "NewerThan") + return + } + // write "OlderThan" + err = en.Append(0xa9, 0x4f, 0x6c, 0x64, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) + if err != nil { + return + } + err = en.WriteDuration(z.OlderThan) + if err != nil { + err = msgp.WrapError(err, "OlderThan") + return + } + // write "CreatedAfter" + err = en.Append(0xac, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72) + if err != nil { + return + } + err = en.WriteTime(z.CreatedAfter) + if err != nil { + err = msgp.WrapError(err, "CreatedAfter") + return + } + // write "CreatedBefore" + err = en.Append(0xad, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65) + if err != nil { + return + } + err = en.WriteTime(z.CreatedBefore) + if err != nil { + err = msgp.WrapError(err, "CreatedBefore") + return + } + // write "Tags" + err = en.Append(0xa4, 0x54, 0x61, 0x67, 0x73) + if err != nil { + return + } + err = en.WriteArrayHeader(uint32(len(z.Tags))) + if err != nil { + err = msgp.WrapError(err, "Tags") + return + } + for za0001 := range z.Tags { + err = z.Tags[za0001].EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Tags", za0001) + return + } + } + // write "Metadata" + err = en.Append(0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) + if err != nil { + return + } + err = en.WriteArrayHeader(uint32(len(z.Metadata))) + if err != nil { + err = msgp.WrapError(err, "Metadata") + return + } + for za0002 := range z.Metadata { + err = z.Metadata[za0002].EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Metadata", za0002) + return + } + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z *BatchReplicateFilter) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 6 + // string "NewerThan" + o = append(o, 0x86, 0xa9, 0x4e, 0x65, 0x77, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) + o = msgp.AppendDuration(o, z.NewerThan) + // string "OlderThan" + o = append(o, 0xa9, 0x4f, 0x6c, 0x64, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e) + o = msgp.AppendDuration(o, z.OlderThan) + // string "CreatedAfter" + o = append(o, 0xac, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72) + o = msgp.AppendTime(o, z.CreatedAfter) + // string "CreatedBefore" + o = append(o, 0xad, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65) + o = msgp.AppendTime(o, z.CreatedBefore) + // string "Tags" + o = append(o, 0xa4, 0x54, 0x61, 0x67, 0x73) + o = msgp.AppendArrayHeader(o, uint32(len(z.Tags))) + for za0001 := range z.Tags { + o, err = z.Tags[za0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Tags", za0001) + return + } + } + // string "Metadata" + o = append(o, 0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) + o = msgp.AppendArrayHeader(o, uint32(len(z.Metadata))) + for za0002 := range z.Metadata { + o, err = z.Metadata[za0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Metadata", za0002) + return + } + } + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BatchReplicateFilter) 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 "NewerThan": + z.NewerThan, bts, err = msgp.ReadDurationBytes(bts) + if err != nil { + err = msgp.WrapError(err, "NewerThan") + return + } + case "OlderThan": + z.OlderThan, bts, err = msgp.ReadDurationBytes(bts) + if err != nil { + err = msgp.WrapError(err, "OlderThan") + return + } + case "CreatedAfter": + z.CreatedAfter, bts, err = msgp.ReadTimeBytes(bts) + if err != nil { + err = msgp.WrapError(err, "CreatedAfter") + return + } + case "CreatedBefore": + z.CreatedBefore, bts, err = msgp.ReadTimeBytes(bts) + if err != nil { + err = msgp.WrapError(err, "CreatedBefore") + return + } + case "Tags": + var zb0002 uint32 + zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Tags") + return + } + if cap(z.Tags) >= int(zb0002) { + z.Tags = (z.Tags)[:zb0002] + } else { + z.Tags = make([]BatchJobKV, zb0002) + } + for za0001 := range z.Tags { + bts, err = z.Tags[za0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Tags", za0001) + return + } + } + case "Metadata": + var zb0003 uint32 + zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Metadata") + return + } + if cap(z.Metadata) >= int(zb0003) { + z.Metadata = (z.Metadata)[:zb0003] + } else { + z.Metadata = make([]BatchJobKV, zb0003) + } + for za0002 := range z.Metadata { + bts, err = z.Metadata[za0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Metadata", za0002) + 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 *BatchReplicateFilter) Msgsize() (s int) { + s = 1 + 10 + msgp.DurationSize + 10 + msgp.DurationSize + 13 + msgp.TimeSize + 14 + msgp.TimeSize + 5 + msgp.ArrayHeaderSize + for za0001 := range z.Tags { + s += z.Tags[za0001].Msgsize() + } + s += 9 + msgp.ArrayHeaderSize + for za0002 := range z.Metadata { + s += z.Metadata[za0002].Msgsize() + } + return +} diff --git a/cmd/batch-replicate_gen_test.go b/cmd/batch-replicate_gen_test.go new file mode 100644 index 000000000..f59a7fe52 --- /dev/null +++ b/cmd/batch-replicate_gen_test.go @@ -0,0 +1,688 @@ +package cmd + +// Code generated by github.com/tinylib/msgp DO NOT EDIT. + +import ( + "bytes" + "testing" + + "github.com/tinylib/msgp/msgp" +) + +func TestMarshalUnmarshalBatchJobReplicateCredentials(t *testing.T) { + v := BatchJobReplicateCredentials{} + 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 BenchmarkMarshalMsgBatchJobReplicateCredentials(b *testing.B) { + v := BatchJobReplicateCredentials{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobReplicateCredentials(b *testing.B) { + v := BatchJobReplicateCredentials{} + 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 BenchmarkUnmarshalBatchJobReplicateCredentials(b *testing.B) { + v := BatchJobReplicateCredentials{} + 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 TestEncodeDecodeBatchJobReplicateCredentials(t *testing.T) { + v := BatchJobReplicateCredentials{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobReplicateCredentials Msgsize() is inaccurate") + } + + vn := BatchJobReplicateCredentials{} + 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 BenchmarkEncodeBatchJobReplicateCredentials(b *testing.B) { + v := BatchJobReplicateCredentials{} + 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 BenchmarkDecodeBatchJobReplicateCredentials(b *testing.B) { + v := BatchJobReplicateCredentials{} + 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 TestMarshalUnmarshalBatchJobReplicateFlags(t *testing.T) { + v := BatchJobReplicateFlags{} + 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 BenchmarkMarshalMsgBatchJobReplicateFlags(b *testing.B) { + v := BatchJobReplicateFlags{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobReplicateFlags(b *testing.B) { + v := BatchJobReplicateFlags{} + 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 BenchmarkUnmarshalBatchJobReplicateFlags(b *testing.B) { + v := BatchJobReplicateFlags{} + 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 TestEncodeDecodeBatchJobReplicateFlags(t *testing.T) { + v := BatchJobReplicateFlags{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobReplicateFlags Msgsize() is inaccurate") + } + + vn := BatchJobReplicateFlags{} + 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 BenchmarkEncodeBatchJobReplicateFlags(b *testing.B) { + v := BatchJobReplicateFlags{} + 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 BenchmarkDecodeBatchJobReplicateFlags(b *testing.B) { + v := BatchJobReplicateFlags{} + 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 TestMarshalUnmarshalBatchJobReplicateSource(t *testing.T) { + v := BatchJobReplicateSource{} + 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 BenchmarkMarshalMsgBatchJobReplicateSource(b *testing.B) { + v := BatchJobReplicateSource{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobReplicateSource(b *testing.B) { + v := BatchJobReplicateSource{} + 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 BenchmarkUnmarshalBatchJobReplicateSource(b *testing.B) { + v := BatchJobReplicateSource{} + 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 TestEncodeDecodeBatchJobReplicateSource(t *testing.T) { + v := BatchJobReplicateSource{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobReplicateSource Msgsize() is inaccurate") + } + + vn := BatchJobReplicateSource{} + 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 BenchmarkEncodeBatchJobReplicateSource(b *testing.B) { + v := BatchJobReplicateSource{} + 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 BenchmarkDecodeBatchJobReplicateSource(b *testing.B) { + v := BatchJobReplicateSource{} + 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 TestMarshalUnmarshalBatchJobReplicateTarget(t *testing.T) { + v := BatchJobReplicateTarget{} + 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 BenchmarkMarshalMsgBatchJobReplicateTarget(b *testing.B) { + v := BatchJobReplicateTarget{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobReplicateTarget(b *testing.B) { + v := BatchJobReplicateTarget{} + 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 BenchmarkUnmarshalBatchJobReplicateTarget(b *testing.B) { + v := BatchJobReplicateTarget{} + 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 TestEncodeDecodeBatchJobReplicateTarget(t *testing.T) { + v := BatchJobReplicateTarget{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobReplicateTarget Msgsize() is inaccurate") + } + + vn := BatchJobReplicateTarget{} + 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 BenchmarkEncodeBatchJobReplicateTarget(b *testing.B) { + v := BatchJobReplicateTarget{} + 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 BenchmarkDecodeBatchJobReplicateTarget(b *testing.B) { + v := BatchJobReplicateTarget{} + 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 TestMarshalUnmarshalBatchJobReplicateV1(t *testing.T) { + v := BatchJobReplicateV1{} + 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 BenchmarkMarshalMsgBatchJobReplicateV1(b *testing.B) { + v := BatchJobReplicateV1{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchJobReplicateV1(b *testing.B) { + v := BatchJobReplicateV1{} + 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 BenchmarkUnmarshalBatchJobReplicateV1(b *testing.B) { + v := BatchJobReplicateV1{} + 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 TestEncodeDecodeBatchJobReplicateV1(t *testing.T) { + v := BatchJobReplicateV1{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchJobReplicateV1 Msgsize() is inaccurate") + } + + vn := BatchJobReplicateV1{} + 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 BenchmarkEncodeBatchJobReplicateV1(b *testing.B) { + v := BatchJobReplicateV1{} + 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 BenchmarkDecodeBatchJobReplicateV1(b *testing.B) { + v := BatchJobReplicateV1{} + 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 TestMarshalUnmarshalBatchReplicateFilter(t *testing.T) { + v := BatchReplicateFilter{} + 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 BenchmarkMarshalMsgBatchReplicateFilter(b *testing.B) { + v := BatchReplicateFilter{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBatchReplicateFilter(b *testing.B) { + v := BatchReplicateFilter{} + 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 BenchmarkUnmarshalBatchReplicateFilter(b *testing.B) { + v := BatchReplicateFilter{} + 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 TestEncodeDecodeBatchReplicateFilter(t *testing.T) { + v := BatchReplicateFilter{} + var buf bytes.Buffer + msgp.Encode(&buf, &v) + + m := v.Msgsize() + if buf.Len() > m { + t.Log("WARNING: TestEncodeDecodeBatchReplicateFilter Msgsize() is inaccurate") + } + + vn := BatchReplicateFilter{} + 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 BenchmarkEncodeBatchReplicateFilter(b *testing.B) { + v := BatchReplicateFilter{} + 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 BenchmarkDecodeBatchReplicateFilter(b *testing.B) { + v := BatchReplicateFilter{} + 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/cmd/batch-rotate.go b/cmd/batch-rotate.go index 0954c81ba..5463f58c7 100644 --- a/cmd/batch-rotate.go +++ b/cmd/batch-rotate.go @@ -35,7 +35,6 @@ import ( "github.com/minio/minio/internal/kms" "github.com/minio/minio/internal/logger" "github.com/minio/pkg/env" - "github.com/minio/pkg/wildcard" "github.com/minio/pkg/workers" ) @@ -72,56 +71,6 @@ import ( //go:generate msgp -file $GOFILE -unexported -// BatchKeyRotateKV is a datatype that holds key and values for filtering of objects -// used by metadata filter as well as tags based filtering. -type BatchKeyRotateKV struct { - Key string `yaml:"key" json:"key"` - Value string `yaml:"value" json:"value"` -} - -// Validate returns an error if key is empty -func (kv BatchKeyRotateKV) Validate() error { - if kv.Key == "" { - return errInvalidArgument - } - return nil -} - -// Empty indicates if kv is not set -func (kv BatchKeyRotateKV) Empty() bool { - return kv.Key == "" && kv.Value == "" -} - -// Match matches input kv with kv, value will be wildcard matched depending on the user input -func (kv BatchKeyRotateKV) Match(ikv BatchKeyRotateKV) bool { - if kv.Empty() { - return true - } - if strings.EqualFold(kv.Key, ikv.Key) { - return wildcard.Match(kv.Value, ikv.Value) - } - return false -} - -// BatchKeyRotateRetry datatype represents total retry attempts and delay between each retries. -type BatchKeyRotateRetry struct { - Attempts int `yaml:"attempts" json:"attempts"` // number of retry attempts - Delay time.Duration `yaml:"delay" json:"delay"` // delay between each retries -} - -// Validate validates input replicate retries. -func (r BatchKeyRotateRetry) Validate() error { - if r.Attempts < 0 { - return errInvalidArgument - } - - if r.Delay < 0 { - return errInvalidArgument - } - - return nil -} - // BatchKeyRotationType defines key rotation type type BatchKeyRotationType string @@ -174,13 +123,13 @@ func (e BatchJobKeyRotateEncryption) Validate() error { // BatchKeyRotateFilter holds all the filters currently supported for batch replication type BatchKeyRotateFilter struct { - NewerThan time.Duration `yaml:"newerThan,omitempty" json:"newerThan"` - OlderThan time.Duration `yaml:"olderThan,omitempty" json:"olderThan"` - CreatedAfter time.Time `yaml:"createdAfter,omitempty" json:"createdAfter"` - CreatedBefore time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` - Tags []BatchKeyRotateKV `yaml:"tags,omitempty" json:"tags"` - Metadata []BatchKeyRotateKV `yaml:"metadata,omitempty" json:"metadata"` - KMSKeyID string `yaml:"kmskeyid" json:"kmskey"` + NewerThan time.Duration `yaml:"newerThan,omitempty" json:"newerThan"` + OlderThan time.Duration `yaml:"olderThan,omitempty" json:"olderThan"` + CreatedAfter time.Time `yaml:"createdAfter,omitempty" json:"createdAfter"` + CreatedBefore time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` + Tags []BatchJobKV `yaml:"tags,omitempty" json:"tags"` + Metadata []BatchJobKV `yaml:"metadata,omitempty" json:"metadata"` + KMSKeyID string `yaml:"kmskeyid" json:"kmskey"` } // BatchKeyRotateNotification success or failure notification endpoint for each job attempts @@ -194,9 +143,9 @@ type BatchKeyRotateNotification struct { // - notify // - retry type BatchJobKeyRotateFlags struct { - Filter BatchKeyRotateFilter `yaml:"filter" json:"filter"` - Notify BatchKeyRotateNotification `yaml:"notify" json:"notify"` - Retry BatchKeyRotateRetry `yaml:"retry" json:"retry"` + Filter BatchKeyRotateFilter `yaml:"filter" json:"filter"` + Notify BatchJobNotification `yaml:"notify" json:"notify"` + Retry BatchJobRetry `yaml:"retry" json:"retry"` } // BatchJobKeyRotateV1 v1 of batch key rotation job @@ -358,7 +307,7 @@ func (r *BatchJobKeyRotateV1) Start(ctx context.Context, api ObjectLayer, job Ba for _, kv := range r.Flags.Filter.Tags { for t, v := range tagMap { - if kv.Match(BatchKeyRotateKV{Key: t, Value: v}) { + if kv.Match(BatchJobKV{Key: t, Value: v}) { return true } } @@ -375,7 +324,7 @@ func (r *BatchJobKeyRotateV1) Start(ctx context.Context, api ObjectLayer, job Ba continue } // We only need to match x-amz-meta or standardHeaders - if kv.Match(BatchKeyRotateKV{Key: k, Value: v}) { + if kv.Match(BatchJobKV{Key: k, Value: v}) { return true } } diff --git a/cmd/batch-rotate_gen.go b/cmd/batch-rotate_gen.go index e6b13b700..b324b83b2 100644 --- a/cmd/batch-rotate_gen.go +++ b/cmd/batch-rotate_gen.go @@ -192,75 +192,17 @@ func (z *BatchJobKeyRotateFlags) DecodeMsg(dc *msgp.Reader) (err error) { return } case "Notify": - var zb0002 uint32 - zb0002, err = dc.ReadMapHeader() + err = z.Notify.DecodeMsg(dc) if err != nil { err = msgp.WrapError(err, "Notify") return } - for zb0002 > 0 { - zb0002-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - switch msgp.UnsafeString(field) { - case "Endpoint": - z.Notify.Endpoint, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Notify", "Endpoint") - return - } - case "Token": - z.Notify.Token, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Notify", "Token") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - } - } case "Retry": - var zb0003 uint32 - zb0003, err = dc.ReadMapHeader() + err = z.Retry.DecodeMsg(dc) if err != nil { err = msgp.WrapError(err, "Retry") return } - for zb0003 > 0 { - zb0003-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - switch msgp.UnsafeString(field) { - case "Attempts": - z.Retry.Attempts, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "Retry", "Attempts") - return - } - case "Delay": - z.Retry.Delay, err = dc.ReadDuration() - if err != nil { - err = msgp.WrapError(err, "Retry", "Delay") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - } - } default: err = dc.Skip() if err != nil { @@ -290,25 +232,9 @@ func (z *BatchJobKeyRotateFlags) EncodeMsg(en *msgp.Writer) (err error) { if err != nil { return } - // map header, size 2 - // write "Endpoint" - err = en.Append(0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) + err = z.Notify.EncodeMsg(en) if err != nil { - return - } - err = en.WriteString(z.Notify.Endpoint) - if err != nil { - err = msgp.WrapError(err, "Notify", "Endpoint") - return - } - // write "Token" - err = en.Append(0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - if err != nil { - return - } - err = en.WriteString(z.Notify.Token) - if err != nil { - err = msgp.WrapError(err, "Notify", "Token") + err = msgp.WrapError(err, "Notify") return } // write "Retry" @@ -316,25 +242,9 @@ func (z *BatchJobKeyRotateFlags) EncodeMsg(en *msgp.Writer) (err error) { if err != nil { return } - // map header, size 2 - // write "Attempts" - err = en.Append(0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) + err = z.Retry.EncodeMsg(en) if err != nil { - return - } - err = en.WriteInt(z.Retry.Attempts) - if err != nil { - err = msgp.WrapError(err, "Retry", "Attempts") - return - } - // write "Delay" - err = en.Append(0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - if err != nil { - return - } - err = en.WriteDuration(z.Retry.Delay) - if err != nil { - err = msgp.WrapError(err, "Retry", "Delay") + err = msgp.WrapError(err, "Retry") return } return @@ -353,22 +263,18 @@ func (z *BatchJobKeyRotateFlags) MarshalMsg(b []byte) (o []byte, err error) { } // string "Notify" o = append(o, 0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) - // map header, size 2 - // string "Endpoint" - o = append(o, 0x82, 0xa8, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74) - o = msgp.AppendString(o, z.Notify.Endpoint) - // string "Token" - o = append(o, 0xa5, 0x54, 0x6f, 0x6b, 0x65, 0x6e) - o = msgp.AppendString(o, z.Notify.Token) + o, err = z.Notify.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Notify") + return + } // string "Retry" o = append(o, 0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) - // map header, size 2 - // string "Attempts" - o = append(o, 0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - o = msgp.AppendInt(o, z.Retry.Attempts) - // string "Delay" - o = append(o, 0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - o = msgp.AppendDuration(o, z.Retry.Delay) + o, err = z.Retry.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Retry") + return + } return } @@ -397,75 +303,17 @@ func (z *BatchJobKeyRotateFlags) UnmarshalMsg(bts []byte) (o []byte, err error) return } case "Notify": - var zb0002 uint32 - zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + bts, err = z.Notify.UnmarshalMsg(bts) if err != nil { err = msgp.WrapError(err, "Notify") return } - for zb0002 > 0 { - zb0002-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - switch msgp.UnsafeString(field) { - case "Endpoint": - z.Notify.Endpoint, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Notify", "Endpoint") - return - } - case "Token": - z.Notify.Token, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Notify", "Token") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Notify") - return - } - } - } case "Retry": - var zb0003 uint32 - zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + bts, err = z.Retry.UnmarshalMsg(bts) if err != nil { err = msgp.WrapError(err, "Retry") return } - for zb0003 > 0 { - zb0003-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - switch msgp.UnsafeString(field) { - case "Attempts": - z.Retry.Attempts, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Retry", "Attempts") - return - } - case "Delay": - z.Retry.Delay, bts, err = msgp.ReadDurationBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Retry", "Delay") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Retry") - return - } - } - } default: bts, err = msgp.Skip(bts) if err != nil { @@ -480,7 +328,7 @@ func (z *BatchJobKeyRotateFlags) UnmarshalMsg(bts []byte) (o []byte, err error) // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *BatchJobKeyRotateFlags) Msgsize() (s int) { - s = 1 + 7 + z.Filter.Msgsize() + 7 + 1 + 9 + msgp.StringPrefixSize + len(z.Notify.Endpoint) + 6 + msgp.StringPrefixSize + len(z.Notify.Token) + 6 + 1 + 9 + msgp.IntSize + 6 + msgp.DurationSize + s = 1 + 7 + z.Filter.Msgsize() + 7 + z.Notify.Msgsize() + 6 + z.Retry.Msgsize() return } @@ -509,11 +357,46 @@ func (z *BatchJobKeyRotateV1) DecodeMsg(dc *msgp.Reader) (err error) { return } case "Flags": - err = z.Flags.DecodeMsg(dc) + var zb0002 uint32 + zb0002, err = dc.ReadMapHeader() if err != nil { err = msgp.WrapError(err, "Flags") return } + for zb0002 > 0 { + zb0002-- + field, err = dc.ReadMapKeyPtr() + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + switch msgp.UnsafeString(field) { + case "Filter": + err = z.Flags.Filter.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + case "Notify": + err = z.Flags.Notify.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + case "Retry": + err = z.Flags.Retry.DecodeMsg(dc) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") + return + } + default: + err = dc.Skip() + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + } + } case "Bucket": z.Bucket, err = dc.ReadString() if err != nil { @@ -567,9 +450,35 @@ func (z *BatchJobKeyRotateV1) EncodeMsg(en *msgp.Writer) (err error) { if err != nil { return } - err = z.Flags.EncodeMsg(en) + // map header, size 3 + // write "Filter" + err = en.Append(0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) if err != nil { - err = msgp.WrapError(err, "Flags") + return + } + err = z.Flags.Filter.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + // write "Notify" + err = en.Append(0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) + if err != nil { + return + } + err = z.Flags.Notify.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + // write "Retry" + err = en.Append(0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) + if err != nil { + return + } + err = z.Flags.Retry.EncodeMsg(en) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") return } // write "Bucket" @@ -624,9 +533,26 @@ func (z *BatchJobKeyRotateV1) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.AppendString(o, z.APIVersion) // string "Flags" o = append(o, 0xa5, 0x46, 0x6c, 0x61, 0x67, 0x73) - o, err = z.Flags.MarshalMsg(o) + // map header, size 3 + // string "Filter" + o = append(o, 0x83, 0xa6, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72) + o, err = z.Flags.Filter.MarshalMsg(o) if err != nil { - err = msgp.WrapError(err, "Flags") + err = msgp.WrapError(err, "Flags", "Filter") + return + } + // string "Notify" + o = append(o, 0xa6, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79) + o, err = z.Flags.Notify.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + // string "Retry" + o = append(o, 0xa5, 0x52, 0x65, 0x74, 0x72, 0x79) + o, err = z.Flags.Retry.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") return } // string "Bucket" @@ -673,11 +599,46 @@ func (z *BatchJobKeyRotateV1) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "Flags": - bts, err = z.Flags.UnmarshalMsg(bts) + var zb0002 uint32 + zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) if err != nil { err = msgp.WrapError(err, "Flags") return } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + switch msgp.UnsafeString(field) { + case "Filter": + bts, err = z.Flags.Filter.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Flags", "Filter") + return + } + case "Notify": + bts, err = z.Flags.Notify.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Flags", "Notify") + return + } + case "Retry": + bts, err = z.Flags.Retry.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Flags", "Retry") + return + } + default: + bts, err = msgp.Skip(bts) + if err != nil { + err = msgp.WrapError(err, "Flags") + return + } + } + } case "Bucket": z.Bucket, bts, err = msgp.ReadStringBytes(bts) if err != nil { @@ -716,7 +677,7 @@ func (z *BatchJobKeyRotateV1) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *BatchJobKeyRotateV1) Msgsize() (s int) { - s = 1 + 11 + msgp.StringPrefixSize + len(z.APIVersion) + 6 + z.Flags.Msgsize() + 7 + msgp.StringPrefixSize + len(z.Bucket) + 7 + msgp.StringPrefixSize + len(z.Prefix) + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 11 + z.Encryption.Msgsize() + s = 1 + 11 + msgp.StringPrefixSize + len(z.APIVersion) + 6 + 1 + 7 + z.Flags.Filter.Msgsize() + 7 + z.Flags.Notify.Msgsize() + 6 + z.Flags.Retry.Msgsize() + 7 + msgp.StringPrefixSize + len(z.Bucket) + 7 + msgp.StringPrefixSize + len(z.Prefix) + 9 + msgp.StringPrefixSize + len(z.Endpoint) + 11 + z.Encryption.Msgsize() return } @@ -772,91 +733,33 @@ func (z *BatchKeyRotateFilter) DecodeMsg(dc *msgp.Reader) (err error) { if cap(z.Tags) >= int(zb0002) { z.Tags = (z.Tags)[:zb0002] } else { - z.Tags = make([]BatchKeyRotateKV, zb0002) + z.Tags = make([]BatchJobKV, zb0002) } for za0001 := range z.Tags { - var zb0003 uint32 - zb0003, err = dc.ReadMapHeader() + err = z.Tags[za0001].DecodeMsg(dc) if err != nil { err = msgp.WrapError(err, "Tags", za0001) return } - for zb0003 > 0 { - zb0003-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Tags[za0001].Key, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Key") - return - } - case "Value": - z.Tags[za0001].Value, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Value") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - } - } } case "Metadata": - var zb0004 uint32 - zb0004, err = dc.ReadArrayHeader() + var zb0003 uint32 + zb0003, err = dc.ReadArrayHeader() if err != nil { err = msgp.WrapError(err, "Metadata") return } - if cap(z.Metadata) >= int(zb0004) { - z.Metadata = (z.Metadata)[:zb0004] + if cap(z.Metadata) >= int(zb0003) { + z.Metadata = (z.Metadata)[:zb0003] } else { - z.Metadata = make([]BatchKeyRotateKV, zb0004) + z.Metadata = make([]BatchJobKV, zb0003) } for za0002 := range z.Metadata { - var zb0005 uint32 - zb0005, err = dc.ReadMapHeader() + err = z.Metadata[za0002].DecodeMsg(dc) if err != nil { err = msgp.WrapError(err, "Metadata", za0002) return } - for zb0005 > 0 { - zb0005-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Metadata[za0002].Key, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Key") - return - } - case "Value": - z.Metadata[za0002].Value, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Value") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - } - } } case "KMSKeyID": z.KMSKeyID, err = dc.ReadString() @@ -929,25 +832,9 @@ func (z *BatchKeyRotateFilter) EncodeMsg(en *msgp.Writer) (err error) { return } for za0001 := range z.Tags { - // map header, size 2 - // write "Key" - err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) + err = z.Tags[za0001].EncodeMsg(en) if err != nil { - return - } - err = en.WriteString(z.Tags[za0001].Key) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Key") - return - } - // write "Value" - err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Tags[za0001].Value) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Value") + err = msgp.WrapError(err, "Tags", za0001) return } } @@ -962,25 +849,9 @@ func (z *BatchKeyRotateFilter) EncodeMsg(en *msgp.Writer) (err error) { return } for za0002 := range z.Metadata { - // map header, size 2 - // write "Key" - err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) + err = z.Metadata[za0002].EncodeMsg(en) if err != nil { - return - } - err = en.WriteString(z.Metadata[za0002].Key) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Key") - return - } - // write "Value" - err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Metadata[za0002].Value) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Value") + err = msgp.WrapError(err, "Metadata", za0002) return } } @@ -1017,25 +888,21 @@ func (z *BatchKeyRotateFilter) MarshalMsg(b []byte) (o []byte, err error) { o = append(o, 0xa4, 0x54, 0x61, 0x67, 0x73) o = msgp.AppendArrayHeader(o, uint32(len(z.Tags))) for za0001 := range z.Tags { - // map header, size 2 - // string "Key" - o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Tags[za0001].Key) - // string "Value" - o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - o = msgp.AppendString(o, z.Tags[za0001].Value) + o, err = z.Tags[za0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Tags", za0001) + return + } } // string "Metadata" o = append(o, 0xa8, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61) o = msgp.AppendArrayHeader(o, uint32(len(z.Metadata))) for za0002 := range z.Metadata { - // map header, size 2 - // string "Key" - o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Metadata[za0002].Key) - // string "Value" - o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - o = msgp.AppendString(o, z.Metadata[za0002].Value) + o, err = z.Metadata[za0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Metadata", za0002) + return + } } // string "KMSKeyID" o = append(o, 0xa8, 0x4b, 0x4d, 0x53, 0x4b, 0x65, 0x79, 0x49, 0x44) @@ -1095,91 +962,33 @@ func (z *BatchKeyRotateFilter) UnmarshalMsg(bts []byte) (o []byte, err error) { if cap(z.Tags) >= int(zb0002) { z.Tags = (z.Tags)[:zb0002] } else { - z.Tags = make([]BatchKeyRotateKV, zb0002) + z.Tags = make([]BatchJobKV, zb0002) } for za0001 := range z.Tags { - var zb0003 uint32 - zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + bts, err = z.Tags[za0001].UnmarshalMsg(bts) if err != nil { err = msgp.WrapError(err, "Tags", za0001) return } - for zb0003 > 0 { - zb0003-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Tags[za0001].Key, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Key") - return - } - case "Value": - z.Tags[za0001].Value, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001, "Value") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Tags", za0001) - return - } - } - } } case "Metadata": - var zb0004 uint32 - zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + var zb0003 uint32 + zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) if err != nil { err = msgp.WrapError(err, "Metadata") return } - if cap(z.Metadata) >= int(zb0004) { - z.Metadata = (z.Metadata)[:zb0004] + if cap(z.Metadata) >= int(zb0003) { + z.Metadata = (z.Metadata)[:zb0003] } else { - z.Metadata = make([]BatchKeyRotateKV, zb0004) + z.Metadata = make([]BatchJobKV, zb0003) } for za0002 := range z.Metadata { - var zb0005 uint32 - zb0005, bts, err = msgp.ReadMapHeaderBytes(bts) + bts, err = z.Metadata[za0002].UnmarshalMsg(bts) if err != nil { err = msgp.WrapError(err, "Metadata", za0002) return } - for zb0005 > 0 { - zb0005-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - switch msgp.UnsafeString(field) { - case "Key": - z.Metadata[za0002].Key, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Key") - return - } - case "Value": - z.Metadata[za0002].Value, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002, "Value") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err, "Metadata", za0002) - return - } - } - } } case "KMSKeyID": z.KMSKeyID, bts, err = msgp.ReadStringBytes(bts) @@ -1203,144 +1012,16 @@ func (z *BatchKeyRotateFilter) UnmarshalMsg(bts []byte) (o []byte, err error) { func (z *BatchKeyRotateFilter) Msgsize() (s int) { s = 1 + 10 + msgp.DurationSize + 10 + msgp.DurationSize + 13 + msgp.TimeSize + 14 + msgp.TimeSize + 5 + msgp.ArrayHeaderSize for za0001 := range z.Tags { - s += 1 + 4 + msgp.StringPrefixSize + len(z.Tags[za0001].Key) + 6 + msgp.StringPrefixSize + len(z.Tags[za0001].Value) + s += z.Tags[za0001].Msgsize() } s += 9 + msgp.ArrayHeaderSize for za0002 := range z.Metadata { - s += 1 + 4 + msgp.StringPrefixSize + len(z.Metadata[za0002].Key) + 6 + msgp.StringPrefixSize + len(z.Metadata[za0002].Value) + s += z.Metadata[za0002].Msgsize() } s += 9 + msgp.StringPrefixSize + len(z.KMSKeyID) return } -// DecodeMsg implements msgp.Decodable -func (z *BatchKeyRotateKV) 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 "Value": - z.Value, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Value") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchKeyRotateKV) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 2 - // write "Key" - err = en.Append(0x82, 0xa3, 0x4b, 0x65, 0x79) - if err != nil { - return - } - err = en.WriteString(z.Key) - if err != nil { - err = msgp.WrapError(err, "Key") - return - } - // write "Value" - err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - if err != nil { - return - } - err = en.WriteString(z.Value) - if err != nil { - err = msgp.WrapError(err, "Value") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchKeyRotateKV) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 2 - // string "Key" - o = append(o, 0x82, 0xa3, 0x4b, 0x65, 0x79) - o = msgp.AppendString(o, z.Key) - // string "Value" - o = append(o, 0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65) - o = msgp.AppendString(o, z.Value) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchKeyRotateKV) 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 "Value": - z.Value, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Value") - 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 BatchKeyRotateKV) Msgsize() (s int) { - s = 1 + 4 + msgp.StringPrefixSize + len(z.Key) + 6 + msgp.StringPrefixSize + len(z.Value) - return -} - // DecodeMsg implements msgp.Decodable func (z *BatchKeyRotateNotification) DecodeMsg(dc *msgp.Reader) (err error) { var field []byte @@ -1469,134 +1150,6 @@ func (z BatchKeyRotateNotification) Msgsize() (s int) { return } -// DecodeMsg implements msgp.Decodable -func (z *BatchKeyRotateRetry) 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 "Attempts": - z.Attempts, err = dc.ReadInt() - if err != nil { - err = msgp.WrapError(err, "Attempts") - return - } - case "Delay": - z.Delay, err = dc.ReadDuration() - if err != nil { - err = msgp.WrapError(err, "Delay") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z BatchKeyRotateRetry) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 2 - // write "Attempts" - err = en.Append(0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - if err != nil { - return - } - err = en.WriteInt(z.Attempts) - if err != nil { - err = msgp.WrapError(err, "Attempts") - return - } - // write "Delay" - err = en.Append(0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - if err != nil { - return - } - err = en.WriteDuration(z.Delay) - if err != nil { - err = msgp.WrapError(err, "Delay") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z BatchKeyRotateRetry) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // map header, size 2 - // string "Attempts" - o = append(o, 0x82, 0xa8, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73) - o = msgp.AppendInt(o, z.Attempts) - // string "Delay" - o = append(o, 0xa5, 0x44, 0x65, 0x6c, 0x61, 0x79) - o = msgp.AppendDuration(o, z.Delay) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *BatchKeyRotateRetry) 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 "Attempts": - z.Attempts, bts, err = msgp.ReadIntBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Attempts") - return - } - case "Delay": - z.Delay, bts, err = msgp.ReadDurationBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Delay") - 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 BatchKeyRotateRetry) Msgsize() (s int) { - s = 1 + 9 + msgp.IntSize + 6 + msgp.DurationSize - return -} - // DecodeMsg implements msgp.Decodable func (z *BatchKeyRotationType) DecodeMsg(dc *msgp.Reader) (err error) { { diff --git a/cmd/batch-rotate_gen_test.go b/cmd/batch-rotate_gen_test.go index bddc57034..5da8f3174 100644 --- a/cmd/batch-rotate_gen_test.go +++ b/cmd/batch-rotate_gen_test.go @@ -461,119 +461,6 @@ func BenchmarkDecodeBatchKeyRotateFilter(b *testing.B) { } } -func TestMarshalUnmarshalBatchKeyRotateKV(t *testing.T) { - v := BatchKeyRotateKV{} - 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 BenchmarkMarshalMsgBatchKeyRotateKV(b *testing.B) { - v := BatchKeyRotateKV{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchKeyRotateKV(b *testing.B) { - v := BatchKeyRotateKV{} - 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 BenchmarkUnmarshalBatchKeyRotateKV(b *testing.B) { - v := BatchKeyRotateKV{} - 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 TestEncodeDecodeBatchKeyRotateKV(t *testing.T) { - v := BatchKeyRotateKV{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchKeyRotateKV Msgsize() is inaccurate") - } - - vn := BatchKeyRotateKV{} - 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 BenchmarkEncodeBatchKeyRotateKV(b *testing.B) { - v := BatchKeyRotateKV{} - 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 BenchmarkDecodeBatchKeyRotateKV(b *testing.B) { - v := BatchKeyRotateKV{} - 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 TestMarshalUnmarshalBatchKeyRotateNotification(t *testing.T) { v := BatchKeyRotateNotification{} bts, err := v.MarshalMsg(nil) @@ -686,116 +573,3 @@ func BenchmarkDecodeBatchKeyRotateNotification(b *testing.B) { } } } - -func TestMarshalUnmarshalBatchKeyRotateRetry(t *testing.T) { - v := BatchKeyRotateRetry{} - 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 BenchmarkMarshalMsgBatchKeyRotateRetry(b *testing.B) { - v := BatchKeyRotateRetry{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgBatchKeyRotateRetry(b *testing.B) { - v := BatchKeyRotateRetry{} - 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 BenchmarkUnmarshalBatchKeyRotateRetry(b *testing.B) { - v := BatchKeyRotateRetry{} - 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 TestEncodeDecodeBatchKeyRotateRetry(t *testing.T) { - v := BatchKeyRotateRetry{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodeBatchKeyRotateRetry Msgsize() is inaccurate") - } - - vn := BatchKeyRotateRetry{} - 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 BenchmarkEncodeBatchKeyRotateRetry(b *testing.B) { - v := BatchKeyRotateRetry{} - 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 BenchmarkDecodeBatchKeyRotateRetry(b *testing.B) { - v := BatchKeyRotateRetry{} - 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) - } - } -}