objstore

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DirDelim = "/"

DirDelim is the delimiter used to model a directory structure in an object store bucket.

Variables

This section is empty.

Functions

func DeleteDir

func DeleteDir(ctx context.Context, bkt Bucket, dir string) error

DeleteDir removes all objects prefixed with dir from the bucket.

func DownloadDir

func DownloadDir(ctx context.Context, logger log.Logger, bkt BucketReader, src, dst string) error

DownloadDir downloads all object found in the directory into the local directory.

func DownloadFile

func DownloadFile(ctx context.Context, logger log.Logger, bkt BucketReader, src, dst string) error

DownloadFile downloads the src file from the bucket to dst. If dst is an existing directory, a file with the same name as the source is created in dst. If destination file is already existing, download file will overwrite it.

func EmptyBucket

func EmptyBucket(t testing.TB, ctx context.Context, bkt Bucket)

EmptyBucket deletes all objects from bucket. This operation is required to properly delete bucket as a whole. It is used for testing only. TODO(bplotka): Add retries.

func UploadDir

func UploadDir(ctx context.Context, logger log.Logger, bkt Bucket, srcdir, dstdir string) error

UploadDir uploads all files in srcdir to the bucket with into a top-level directory named dstdir. It is a caller responsibility to clean partial upload in case of failure.

func UploadFile

func UploadFile(ctx context.Context, logger log.Logger, bkt Bucket, src, dst string) error

UploadFile uploads the file with the given name to the bucket. It is a caller responsibility to clean partial upload in case of failure

Types

type Bucket

type Bucket interface {
	io.Closer
	BucketReader

	// Upload the contents of the reader as an object into the bucket.
	Upload(ctx context.Context, name string, r io.Reader) error

	// Delete removes the object with the given name.
	Delete(ctx context.Context, name string) error

	// Name returns the bucket name for the provider.
	Name() string
}

Bucket provides read and write access to an object storage bucket. NOTE: We assume strong consistency for write-read flow.

func BucketWithMetrics

func BucketWithMetrics(name string, b Bucket, r prometheus.Registerer) Bucket

BucketWithMetrics takes a bucket and registers metrics with the given registry for operations run against the bucket.

type BucketReader

type BucketReader interface {
	// 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.
	Iter(ctx context.Context, dir string, f func(string) error) error

	// Get returns a reader for the given object name.
	Get(ctx context.Context, name string) (io.ReadCloser, error)

	// GetRange returns a new range reader for the given object name and range.
	GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)

	// Exists checks if the given object exists in the bucket.
	// TODO(bplotka): Consider removing Exists in favor of helper that do Get & IsObjNotFoundErr (less code to maintain).
	Exists(ctx context.Context, name string) (bool, error)

	// IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations.
	IsObjNotFoundErr(err error) bool
}

BucketReader provides read access to an object storage bucket.

Directories

Path Synopsis
Package gcs implements common object storage abstractions against Google Cloud Storage.
Package gcs implements common object storage abstractions against Google Cloud Storage.
Package s3 implements common object storage abstractions against s3-compatible APIs.
Package s3 implements common object storage abstractions against s3-compatible APIs.
Package swift implements common object storage abstractions against OpenStack swift APIs.
Package swift implements common object storage abstractions against OpenStack swift APIs.

Jump to

Keyboard shortcuts

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