storage

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage provides a portable storage bucket API with cross-cutting concerns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

Bucket is the portable storage type wrapping a driver with cross-cutting concerns.

func NewBucket

func NewBucket(d driver.Bucket, opts ...Option) *Bucket

NewBucket creates a new portable Bucket wrapping the given driver.

func (*Bucket) AbortMultipartUpload added in v1.2.0

func (b *Bucket) AbortMultipartUpload(ctx context.Context, bucket, key, uploadID string) error

AbortMultipartUpload aborts a multipart upload and removes all uploaded parts.

func (*Bucket) CompleteMultipartUpload added in v1.2.0

func (b *Bucket) CompleteMultipartUpload(
	ctx context.Context, bucket, key, uploadID string, parts []driver.UploadPart,
) error

CompleteMultipartUpload completes a multipart upload by assembling all parts.

func (*Bucket) CopyObject

func (b *Bucket) CopyObject(ctx context.Context, dstBucket, dstKey string, src driver.CopySource) error

CopyObject copies an object between buckets.

func (*Bucket) CreateBucket

func (b *Bucket) CreateBucket(ctx context.Context, name string) error

CreateBucket creates a new storage bucket.

func (*Bucket) CreateMultipartUpload added in v1.2.0

func (b *Bucket) CreateMultipartUpload(
	ctx context.Context, bucket, key, contentType string,
) (*driver.MultipartUpload, error)

CreateMultipartUpload initiates a multipart upload.

func (*Bucket) DeleteBucket

func (b *Bucket) DeleteBucket(ctx context.Context, name string) error

DeleteBucket deletes a storage bucket.

func (*Bucket) DeleteObject

func (b *Bucket) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject deletes an object from a bucket.

func (*Bucket) EvaluateLifecycle added in v1.2.0

func (b *Bucket) EvaluateLifecycle(ctx context.Context, bucket string) ([]string, error)

EvaluateLifecycle evaluates lifecycle rules and returns keys eligible for expiration.

func (*Bucket) GeneratePresignedURL added in v1.2.0

func (b *Bucket) GeneratePresignedURL(ctx context.Context, req driver.PresignedURLRequest) (*driver.PresignedURL, error)

GeneratePresignedURL generates a presigned URL for an object.

func (*Bucket) GetBucketVersioning added in v1.2.0

func (b *Bucket) GetBucketVersioning(ctx context.Context, bucket string) (bool, error)

GetBucketVersioning returns whether versioning is enabled on a bucket.

func (*Bucket) GetLifecycleConfig added in v1.2.0

func (b *Bucket) GetLifecycleConfig(ctx context.Context, bucket string) (*driver.LifecycleConfig, error)

GetLifecycleConfig retrieves the lifecycle configuration for a bucket.

func (*Bucket) GetObject

func (b *Bucket) GetObject(ctx context.Context, bucket, key string) (*driver.Object, error)

GetObject retrieves an object from a bucket.

func (*Bucket) HeadObject

func (b *Bucket) HeadObject(ctx context.Context, bucket, key string) (*driver.ObjectInfo, error)

HeadObject retrieves object metadata without the body.

func (*Bucket) ListBuckets

func (b *Bucket) ListBuckets(ctx context.Context) ([]driver.BucketInfo, error)

ListBuckets lists all buckets.

func (*Bucket) ListMultipartUploads added in v1.2.0

func (b *Bucket) ListMultipartUploads(ctx context.Context, bucket string) ([]driver.MultipartUpload, error)

ListMultipartUploads lists active multipart uploads for a bucket.

func (*Bucket) ListObjects

func (b *Bucket) ListObjects(ctx context.Context, bucket string, opts driver.ListOptions) (*driver.ListResult, error)

ListObjects lists objects in a bucket.

func (*Bucket) PutLifecycleConfig added in v1.2.0

func (b *Bucket) PutLifecycleConfig(ctx context.Context, bucket string, config driver.LifecycleConfig) error

PutLifecycleConfig sets a lifecycle configuration on a bucket.

func (*Bucket) PutObject

func (b *Bucket) PutObject(ctx context.Context, bucket, key string, data []byte, contentType string, metadata map[string]string) error

PutObject stores an object in a bucket.

func (*Bucket) SetBucketVersioning added in v1.2.0

func (b *Bucket) SetBucketVersioning(ctx context.Context, bucket string, enabled bool) error

SetBucketVersioning enables or disables versioning on a bucket.

func (*Bucket) UploadPart added in v1.2.0

func (b *Bucket) UploadPart(
	ctx context.Context, bucket, key, uploadID string, partNumber int, data []byte,
) (*driver.UploadPart, error)

UploadPart uploads a part of a multipart upload.

type Option

type Option func(*Bucket)

Option configures a portable Bucket.

func WithErrorInjection

func WithErrorInjection(i *inject.Injector) Option

WithErrorInjection sets the error injector.

func WithLatency

func WithLatency(d time.Duration) Option

WithLatency sets simulated latency.

func WithMetrics

func WithMetrics(m *metrics.Collector) Option

WithMetrics sets the metrics collector.

func WithRateLimiter

func WithRateLimiter(l *ratelimit.Limiter) Option

WithRateLimiter sets the rate limiter.

func WithRecorder

func WithRecorder(r *recorder.Recorder) Option

WithRecorder sets the recorder.

Directories

Path Synopsis
Package driver defines the interface for storage service implementations.
Package driver defines the interface for storage service implementations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL