Documentation ¶
Index ¶
- Variables
- func DeletePrefix(ctx context.Context, bkt objstore.Bucket, prefix string, logger log.Logger) (int, error)
- func IsNotExist(b objstore.BucketReader, err error) bool
- func NewDelayedBucketClient(wrapped objstore.Bucket, minDelay, maxDelay time.Duration) objstore.Bucket
- func ReadRange(ctx context.Context, reader io.ReaderFrom, name string, ...) error
- func UnwrapErr(err error) error
- type Bucket
- type BucketReader
- type BucketReaderWithOffset
- type ClientMock
- func (m *ClientMock) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
- func (m *ClientMock) Close() error
- func (m *ClientMock) Delete(ctx context.Context, name string) error
- func (m *ClientMock) Exists(ctx context.Context, name string) (bool, error)
- func (m *ClientMock) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (m *ClientMock) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
- func (m *ClientMock) IsAccessDeniedErr(_ error) bool
- func (m *ClientMock) IsObjNotFoundErr(err error) bool
- func (m *ClientMock) Iter(ctx context.Context, dir string, f func(string) error, ...) error
- func (m *ClientMock) MockAttributes(name string, attrs objstore.ObjectAttributes, err error)
- func (m *ClientMock) MockDelete(name string, err error)
- func (m *ClientMock) MockExists(name string, exists bool, err error)
- func (m *ClientMock) MockGet(name, content string, err error)
- func (m *ClientMock) MockGetAndLastModified(name, content string, lastModified time.Time, err error)
- func (m *ClientMock) MockIter(prefix string, objects []string, err error)
- func (m *ClientMock) MockIterWithCallback(prefix string, objects []string, err error, cb func())
- func (m *ClientMock) MockUpload(name string, err error)
- func (m *ClientMock) Name() string
- func (m *ClientMock) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
- func (m *ClientMock) Upload(ctx context.Context, name string, r io.Reader) error
- type DelayedBucketClient
- func (m *DelayedBucketClient) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
- func (m *DelayedBucketClient) Close() error
- func (m *DelayedBucketClient) Delete(ctx context.Context, name string) error
- func (m *DelayedBucketClient) Exists(ctx context.Context, name string) (bool, error)
- func (m *DelayedBucketClient) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (m *DelayedBucketClient) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
- func (m *DelayedBucketClient) IsAccessDeniedErr(err error) bool
- func (m *DelayedBucketClient) IsObjNotFoundErr(err error) bool
- func (m *DelayedBucketClient) Iter(ctx context.Context, dir string, f func(string) error, ...) error
- func (m *DelayedBucketClient) Name() string
- func (m *DelayedBucketClient) Upload(ctx context.Context, name string, r io.Reader) error
- type GetRangeReader
- type InstrumentedBucket
- type IsOpFailureExpectedFunc
- type PrefixedBucket
- func (p PrefixedBucket) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
- func (p *PrefixedBucket) Close() error
- func (p *PrefixedBucket) Delete(ctx context.Context, name string) error
- func (p *PrefixedBucket) Exists(ctx context.Context, name string) (bool, error)
- func (p *PrefixedBucket) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (p *PrefixedBucket) GetRange(ctx context.Context, name string, off int64, length int64) (io.ReadCloser, error)
- func (p *PrefixedBucket) IsObjNotFoundErr(err error) bool
- func (p *PrefixedBucket) Iter(ctx context.Context, dir string, f func(string) error, ...) error
- func (p *PrefixedBucket) Name() string
- func (p *PrefixedBucket) Prefix() string
- func (p *PrefixedBucket) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
- func (p *PrefixedBucket) ReaderWithExpectedErrs(fn IsOpFailureExpectedFunc) BucketReader
- func (p *PrefixedBucket) Upload(ctx context.Context, name string, r io.Reader) error
- func (p *PrefixedBucket) WithExpectedErrs(fn IsOpFailureExpectedFunc) Bucket
- type ReadOnlyFile
- func (f *ReadOnlyFile) Attributes(_ context.Context, name string) (attrs objstore.ObjectAttributes, err error)
- func (f *ReadOnlyFile) Close() error
- func (f *ReadOnlyFile) Exists(_ context.Context, name string) (bool, error)
- func (f *ReadOnlyFile) Get(_ context.Context, name string) (io.ReadCloser, error)
- func (f *ReadOnlyFile) GetRange(_ context.Context, name string, off, length int64) (io.ReadCloser, error)
- func (f *ReadOnlyFile) IsAccessDeniedErr(err error) bool
- func (f *ReadOnlyFile) IsObjNotFoundErr(err error) bool
- func (f *ReadOnlyFile) Iter(context.Context, string, func(string) error, ...objstore.IterOption) error
- func (f *ReadOnlyFile) ReaderAt(_ context.Context, name string) (ReaderAtCloser, error)
- type ReaderAt
- type ReaderAtBucket
- type ReaderAtCloser
- type SSEBucketClient
- func (b *SSEBucketClient) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
- func (b *SSEBucketClient) Close() error
- func (b *SSEBucketClient) Delete(ctx context.Context, name string) error
- func (b *SSEBucketClient) Exists(ctx context.Context, name string) (bool, error)
- func (b *SSEBucketClient) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (b *SSEBucketClient) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
- func (b *SSEBucketClient) IsAccessDeniedErr(err error) bool
- func (b *SSEBucketClient) IsObjNotFoundErr(err error) bool
- func (b *SSEBucketClient) Iter(ctx context.Context, dir string, f func(string) error, ...) error
- func (b *SSEBucketClient) Name() string
- func (b *SSEBucketClient) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
- func (b *SSEBucketClient) ReaderWithExpectedErrs(fn IsOpFailureExpectedFunc) BucketReader
- func (b *SSEBucketClient) Upload(ctx context.Context, name string, r io.Reader) error
- func (b *SSEBucketClient) WithExpectedErrs(fn IsOpFailureExpectedFunc) Bucket
- type TenantConfigProvider
Constants ¶
This section is empty.
Variables ¶
var ErrObjectDoesNotExist = errors.New("object does not exist")
ErrObjectDoesNotExist is used in tests to simulate objstore.Bucket.IsObjNotFoundErr().
Functions ¶
func DeletePrefix ¶
func DeletePrefix(ctx context.Context, bkt objstore.Bucket, prefix string, logger log.Logger) (int, error)
DeletePrefix removes all objects with given prefix, recursively. It returns number of deleted objects. If deletion of any object fails, it returns error and stops.
func IsNotExist ¶ added in v1.11.0
func IsNotExist(b objstore.BucketReader, err error) bool
func NewDelayedBucketClient ¶
Types ¶
type Bucket ¶
type Bucket interface { objstore.Bucket ReaderAt(ctx context.Context, filename string) (ReaderAtCloser, error) }
func NewPrefixedBucket ¶
type BucketReader ¶
type BucketReader interface { objstore.BucketReader ReaderAt(ctx context.Context, filename string) (ReaderAtCloser, error) }
type BucketReaderWithOffset ¶ added in v1.8.0
type BucketReaderWithOffset struct { BucketReader // contains filtered or unexported fields }
func NewBucketReaderWithOffset ¶ added in v1.8.0
func NewBucketReaderWithOffset(r BucketReader, offset int64) *BucketReaderWithOffset
func (*BucketReaderWithOffset) GetRange ¶ added in v1.8.0
func (r *BucketReaderWithOffset) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
type ClientMock ¶ added in v1.1.0
ClientMock mocks objstore.Bucket
func (*ClientMock) Attributes ¶ added in v1.1.0
func (m *ClientMock) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
ObjectSize mocks objstore.Bucket.Attributes()
func (*ClientMock) Close ¶ added in v1.1.0
func (m *ClientMock) Close() error
Close mocks objstore.Bucket.Close()
func (*ClientMock) Delete ¶ added in v1.1.0
func (m *ClientMock) Delete(ctx context.Context, name string) error
Delete mocks objstore.Bucket.Delete()
func (*ClientMock) Get ¶ added in v1.1.0
func (m *ClientMock) Get(ctx context.Context, name string) (io.ReadCloser, error)
Get mocks objstore.Bucket.Get()
func (*ClientMock) GetRange ¶ added in v1.1.0
func (m *ClientMock) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
GetRange mocks objstore.Bucket.GetRange()
func (*ClientMock) IsAccessDeniedErr ¶ added in v1.2.1
func (m *ClientMock) IsAccessDeniedErr(_ error) bool
func (*ClientMock) IsObjNotFoundErr ¶ added in v1.1.0
func (m *ClientMock) IsObjNotFoundErr(err error) bool
IsObjNotFoundErr mocks objstore.Bucket.IsObjNotFoundErr()
func (*ClientMock) Iter ¶ added in v1.1.0
func (m *ClientMock) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) error
Iter mocks objstore.Bucket.Iter()
func (*ClientMock) MockAttributes ¶ added in v1.1.0
func (m *ClientMock) MockAttributes(name string, attrs objstore.ObjectAttributes, err error)
func (*ClientMock) MockDelete ¶ added in v1.1.0
func (m *ClientMock) MockDelete(name string, err error)
func (*ClientMock) MockExists ¶ added in v1.1.0
func (m *ClientMock) MockExists(name string, exists bool, err error)
func (*ClientMock) MockGet ¶ added in v1.1.0
func (m *ClientMock) MockGet(name, content string, err error)
MockGet is a convenient method to mock Get() and Exists()
func (*ClientMock) MockGetAndLastModified ¶ added in v1.1.0
func (m *ClientMock) MockGetAndLastModified(name, content string, lastModified time.Time, err error)
func (*ClientMock) MockIter ¶ added in v1.1.0
func (m *ClientMock) MockIter(prefix string, objects []string, err error)
MockIter is a convenient method to mock Iter()
func (*ClientMock) MockIterWithCallback ¶ added in v1.1.0
func (m *ClientMock) MockIterWithCallback(prefix string, objects []string, err error, cb func())
MockIterWithCallback is a convenient method to mock Iter() and get a callback called when the Iter API is called.
func (*ClientMock) MockUpload ¶ added in v1.1.0
func (m *ClientMock) MockUpload(name string, err error)
func (*ClientMock) Name ¶ added in v1.1.0
func (m *ClientMock) Name() string
Name mocks objstore.Bucket.Name()
func (*ClientMock) ReaderAt ¶ added in v1.1.0
func (m *ClientMock) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
type DelayedBucketClient ¶
type DelayedBucketClient struct {
// contains filtered or unexported fields
}
DelayedBucketClient wraps objstore.InstrumentedBucket and add a random delay to each API call. This client is intended to be used only for testing purposes.
func (*DelayedBucketClient) Attributes ¶
func (m *DelayedBucketClient) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
func (*DelayedBucketClient) Close ¶
func (m *DelayedBucketClient) Close() error
func (*DelayedBucketClient) Delete ¶
func (m *DelayedBucketClient) Delete(ctx context.Context, name string) error
func (*DelayedBucketClient) Get ¶
func (m *DelayedBucketClient) Get(ctx context.Context, name string) (io.ReadCloser, error)
func (*DelayedBucketClient) GetRange ¶
func (m *DelayedBucketClient) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
func (*DelayedBucketClient) IsAccessDeniedErr ¶ added in v1.2.1
func (m *DelayedBucketClient) IsAccessDeniedErr(err error) bool
IsAccessDeniedErr returns true if acces to object is denied.
func (*DelayedBucketClient) IsObjNotFoundErr ¶
func (m *DelayedBucketClient) IsObjNotFoundErr(err error) bool
func (*DelayedBucketClient) Iter ¶
func (m *DelayedBucketClient) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) error
func (*DelayedBucketClient) Name ¶
func (m *DelayedBucketClient) Name() string
type GetRangeReader ¶
type InstrumentedBucket ¶ added in v1.1.0
type InstrumentedBucket interface { Bucket // WithExpectedErrs allows to specify a filter that marks certain errors as expected, so it will not increment // objstore_bucket_operation_failures_total metric. WithExpectedErrs(IsOpFailureExpectedFunc) Bucket // ReaderWithExpectedErrs allows to specify a filter that marks certain errors as expected, so it will not increment // objstore_bucket_operation_failures_total metric. // TODO(bwplotka): Remove this when moved to Go 1.14 and replace with InstrumentedBucketReader. ReaderWithExpectedErrs(IsOpFailureExpectedFunc) BucketReader }
func NewSSEBucketClient ¶
func NewSSEBucketClient(userID string, bucket Bucket, cfgProvider TenantConfigProvider) InstrumentedBucket
NewSSEBucketClient makes a new SSEBucketClient. The cfgProvider can be nil.
func NewTenantBucketClient ¶ added in v1.2.0
func NewTenantBucketClient(tenantID string, bucket Bucket, cfgProvider TenantConfigProvider) InstrumentedBucket
NewTenantBucketClient returns a bucket client to use to access the storage on behalf of the provided user. The cfgProvider can be nil.
type IsOpFailureExpectedFunc ¶ added in v1.1.0
IsOpFailureExpectedFunc allows to mark certain errors as expected, so they will not increment objstore_bucket_operation_failures_total metric.
type PrefixedBucket ¶
type PrefixedBucket struct { Bucket // contains filtered or unexported fields }
func (PrefixedBucket) Attributes ¶
func (p PrefixedBucket) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
Attributes returns information about the specified object.
func (*PrefixedBucket) Close ¶
func (p *PrefixedBucket) Close() error
func (*PrefixedBucket) Delete ¶
func (p *PrefixedBucket) Delete(ctx context.Context, name string) error
Delete removes the object with the given name. If object does not exists in the moment of deletion, Delete should throw error.
func (*PrefixedBucket) Get ¶
func (p *PrefixedBucket) Get(ctx context.Context, name string) (io.ReadCloser, error)
Get returns a reader for the given object name.
func (*PrefixedBucket) GetRange ¶
func (p *PrefixedBucket) GetRange(ctx context.Context, name string, off int64, length int64) (io.ReadCloser, error)
GetRange returns a new range reader for the given object name and range.
func (*PrefixedBucket) IsObjNotFoundErr ¶
func (p *PrefixedBucket) IsObjNotFoundErr(err error) bool
IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations.
func (*PrefixedBucket) Iter ¶
func (p *PrefixedBucket) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) error
Iter calls f for each entry in the given directory (not recursive.). The argument to f is the full object name including the prefix of the inspected directory. Entries are passed to function in sorted order.
func (*PrefixedBucket) Name ¶
func (p *PrefixedBucket) Name() string
Name returns the bucket name for the provider.
func (*PrefixedBucket) Prefix ¶
func (p *PrefixedBucket) Prefix() string
func (*PrefixedBucket) ReaderAt ¶
func (p *PrefixedBucket) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
func (*PrefixedBucket) ReaderWithExpectedErrs ¶ added in v1.1.0
func (p *PrefixedBucket) ReaderWithExpectedErrs(fn IsOpFailureExpectedFunc) BucketReader
ReaderWithExpectedErrs implements objstore.Bucket.
func (*PrefixedBucket) Upload ¶
Upload the contents of the reader as an object into the bucket. Upload should be idempotent.
func (*PrefixedBucket) WithExpectedErrs ¶ added in v1.1.0
func (p *PrefixedBucket) WithExpectedErrs(fn IsOpFailureExpectedFunc) Bucket
WithExpectedErrs implements objstore.Bucket.
type ReadOnlyFile ¶ added in v1.8.0
type ReadOnlyFile struct {
// contains filtered or unexported fields
}
func Download ¶ added in v1.8.0
func Download(ctx context.Context, name string, src BucketReader, dir string) (*ReadOnlyFile, error)
func (*ReadOnlyFile) Attributes ¶ added in v1.8.0
func (f *ReadOnlyFile) Attributes(_ context.Context, name string) (attrs objstore.ObjectAttributes, err error)
func (*ReadOnlyFile) Close ¶ added in v1.8.0
func (f *ReadOnlyFile) Close() error
func (*ReadOnlyFile) Get ¶ added in v1.8.0
func (f *ReadOnlyFile) Get(_ context.Context, name string) (io.ReadCloser, error)
func (*ReadOnlyFile) GetRange ¶ added in v1.8.0
func (f *ReadOnlyFile) GetRange(_ context.Context, name string, off, length int64) (io.ReadCloser, error)
func (*ReadOnlyFile) IsAccessDeniedErr ¶ added in v1.8.0
func (f *ReadOnlyFile) IsAccessDeniedErr(err error) bool
func (*ReadOnlyFile) IsObjNotFoundErr ¶ added in v1.8.0
func (f *ReadOnlyFile) IsObjNotFoundErr(err error) bool
func (*ReadOnlyFile) Iter ¶ added in v1.8.0
func (f *ReadOnlyFile) Iter(context.Context, string, func(string) error, ...objstore.IterOption) error
func (*ReadOnlyFile) ReaderAt ¶ added in v1.8.0
func (f *ReadOnlyFile) ReaderAt(_ context.Context, name string) (ReaderAtCloser, error)
type ReaderAt ¶
type ReaderAt struct { GetRangeReader // contains filtered or unexported fields }
type ReaderAtBucket ¶
func (*ReaderAtBucket) ReaderAt ¶
func (b *ReaderAtBucket) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
func (*ReaderAtBucket) ReaderWithExpectedErrs ¶ added in v1.1.0
func (b *ReaderAtBucket) ReaderWithExpectedErrs(fn IsOpFailureExpectedFunc) BucketReader
ReaderWithExpectedErrs implements objstore.Bucket.
func (*ReaderAtBucket) WithExpectedErrs ¶ added in v1.1.0
func (b *ReaderAtBucket) WithExpectedErrs(fn IsOpFailureExpectedFunc) Bucket
WithExpectedErrs implements objstore.Bucket.
type SSEBucketClient ¶
type SSEBucketClient struct {
// contains filtered or unexported fields
}
SSEBucketClient is a wrapper around a objstore.BucketReader that configures the object storage server-side encryption (SSE) for a given user.
func (*SSEBucketClient) Attributes ¶
func (b *SSEBucketClient) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
Attributes implements objstore.Bucket.
func (*SSEBucketClient) Close ¶
func (b *SSEBucketClient) Close() error
Close implements objstore.Bucket.
func (*SSEBucketClient) Delete ¶
func (b *SSEBucketClient) Delete(ctx context.Context, name string) error
Delete implements objstore.Bucket.
func (*SSEBucketClient) Get ¶
func (b *SSEBucketClient) Get(ctx context.Context, name string) (io.ReadCloser, error)
Get implements objstore.Bucket.
func (*SSEBucketClient) GetRange ¶
func (b *SSEBucketClient) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
GetRange implements objstore.Bucket.
func (*SSEBucketClient) IsAccessDeniedErr ¶ added in v1.2.1
func (b *SSEBucketClient) IsAccessDeniedErr(err error) bool
IsAccessDeniedErr returns true if acces to object is denied.
func (*SSEBucketClient) IsObjNotFoundErr ¶
func (b *SSEBucketClient) IsObjNotFoundErr(err error) bool
IsObjNotFoundErr implements objstore.Bucket.
func (*SSEBucketClient) Iter ¶
func (b *SSEBucketClient) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) error
Iter implements objstore.Bucket.
func (*SSEBucketClient) Name ¶
func (b *SSEBucketClient) Name() string
Name implements objstore.Bucket.
func (*SSEBucketClient) ReaderAt ¶ added in v1.1.0
func (b *SSEBucketClient) ReaderAt(ctx context.Context, name string) (ReaderAtCloser, error)
func (*SSEBucketClient) ReaderWithExpectedErrs ¶
func (b *SSEBucketClient) ReaderWithExpectedErrs(fn IsOpFailureExpectedFunc) BucketReader
ReaderWithExpectedErrs implements objstore.Bucket.
func (*SSEBucketClient) WithExpectedErrs ¶
func (b *SSEBucketClient) WithExpectedErrs(fn IsOpFailureExpectedFunc) Bucket
WithExpectedErrs implements objstore.Bucket.
type TenantConfigProvider ¶
type TenantConfigProvider interface { // S3SSEType returns the per-tenant S3 SSE type. S3SSEType(userID string) string // S3SSEKMSKeyID returns the per-tenant S3 KMS-SSE key id or an empty string if not set. S3SSEKMSKeyID(userID string) string // S3SSEKMSEncryptionContext returns the per-tenant S3 KMS-SSE key id or an empty string if not set. S3SSEKMSEncryptionContext(userID string) string }
TenantConfigProvider defines a per-tenant config provider.