blob

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package blob provides types for interacting with blob storage providers such as S3, GCS etc.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist is the error given when performing an action against an object that does not exist.
	ErrNotExist = errors.New("does not exist")
)

Functions

This section is empty.

Types

type Bucket

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

The Bucket type is used to read, write & delete objects from a blob storage provider.

func NewBucket

func NewBucket(ctx context.Context, bucketURL string) (*Bucket, error)

NewBucket returns a new instance of the Bucket type that performs actions against a blob storage provider. The provider is determined by the URL string. See the gocloud.dev documentation for information on provider specific URLs.

func (*Bucket) Check added in v0.9.0

func (b *Bucket) Check(ctx context.Context) error

Check determines if the bucket is accessible. This method is used to implement the operation.Checker interface for use in health checks.

func (*Bucket) Close

func (b *Bucket) Close() error

Close the connection to the blob store.

func (*Bucket) Delete

func (b *Bucket) Delete(ctx context.Context, path string) error

Delete an object at a specified path. Returns ErrNotExist if the object does not exist.

func (*Bucket) Exists

func (b *Bucket) Exists(ctx context.Context, path string) (bool, error)

Exists returns true if an object exists at the given path.

func (*Bucket) List

func (b *Bucket) List(ctx context.Context, filter Filter) iter.Seq2[Object, error]

List objects within the bucket that match the given Filter. Provide a nil Filter to return all objects. This method returns an iterator so is used with a range statement. The second range parameter is an error that must be checked on each iteration.

func (*Bucket) Name added in v0.9.0

func (b *Bucket) Name() string

Name returns "blob". This method is used to implement the operation.Checker interface for use in health checks.

func (*Bucket) NewReader

func (b *Bucket) NewReader(ctx context.Context, path string) (io.ReadCloser, error)

NewReader returns an io.ReadCloser implementation that reads data from blob storage at a given path. Returns ErrNotExist if there is no object at the specified path. The reader must be closed by the caller.

func (*Bucket) NewWriter

func (b *Bucket) NewWriter(ctx context.Context, path string) (io.WriteCloser, error)

NewWriter returns an io.WriteCloser implementation that writes data to the blob store at a given path. The writer must by closed by the caller.

type Filter added in v0.5.0

type Filter func(obj Object) bool

The Filter function allows callers of Bucket.List to programmatically filter results.

type Object

type Object struct {
	// The object's key.
	Key string
	// The object's size in bytes.
	Size int64
	// When the object was last modified.
	LastModified time.Time
}

The Object type contains metadata on an object within the blob store.

Jump to

Keyboard shortcuts

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