bucket

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: BSD-3-Clause Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketSchemes

func BucketSchemes() []string

BucketSchemes returns the list of schemes that have been registered.

func RegisterBucket

func RegisterBucket(ctx context.Context, scheme string, init_func BucketInitializationFunc) error

RegisterBucket registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Bucket` instances by the `NewBucket` method.

func RegisterGoCloudBuckets

func RegisterGoCloudBuckets(ctx context.Context) error

RegisterGoCloudBuckets will explicitly register all the schemes associated with the `gocloud.dev/blob.Bucket` interface.

Types

type Attributes

type Attributes struct {
	ModTime time.Time
	Size    int64
}

type BlobBucket

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

BlobBucket implements the `Bucket` interface using a `gocloud.dev/blob.Bucket` instance.

func (*BlobBucket) Attributes

func (b *BlobBucket) Attributes(ctx context.Context, path string) (*Attributes, error)

Attributes returns an `Attributes` struct for the record named 'key' in'b'.

func (*BlobBucket) Close

func (b *BlobBucket) Close() error

Close tells 'b' to wrap things up.

func (*BlobBucket) Delete

func (b *BlobBucket) Delete(ctx context.Context, key string) error

Delete removes the record named 'key' in 'b'.

func (*BlobBucket) GatherPictures

func (b *BlobBucket) GatherPictures(ctx context.Context, uris ...string) iter.Seq2[string, error]

GatherPictures will return a iterator listing items in 'b'

func (*BlobBucket) NewReader

func (b *BlobBucket) NewReader(ctx context.Context, key string, opts any) (io.ReadSeekCloser, error)

NewReader returns an `io.ReadSeekCloser` instance for the record named 'key' in 'b'.

func (*BlobBucket) NewWriter

func (b *BlobBucket) NewWriter(ctx context.Context, key string, opts any) (io.WriteCloser, error)

NewWriter returns an `io.WriterCloser` instance for writing to the record named 'key' in 'b'.

type Bucket

type Bucket interface {
	// GatherPictures returns an iterator for listing Picturebook images URIs that can passed to the (bucket implementation's) `NewReader` method.
	GatherPictures(context.Context, ...string) iter.Seq2[string, error]
	// NewReader returns an `io.ReadSeekCloser` instance for a record in the bucket.
	NewReader(context.Context, string, any) (io.ReadSeekCloser, error)
	// NewWriter returns an `io.WriterCloser` instance for writing a record to the bucket.
	NewWriter(context.Context, string, any) (io.WriteCloser, error)
	// Delete removed a record from the bucket.
	Delete(context.Context, string) error
	// Attributes returns an `Attributes` struct for a record in the bucket.
	Attributes(context.Context, string) (*Attributes, error)
	// Close signals the implementation to wrap things up (internally).
	Close() error
}

Bucket implements a simple interface for reading and writing Picturebook images to and from different storage implementations. It is modeled after the `gocloud.dev/blob.Bucket` interface which is what this package used to use. This simplified interface reflects the limited methods from the original interface that were used. The goal is to make it easier to implement a variety of Picturebook "sources" (or buckets) without having to implement the entirety of the `gocloud.dev/blob.Bucket` interface.

func NewBlobBucket

func NewBlobBucket(ctx context.Context, uri string) (Bucket, error)

NewBlobBucket returns a new instantiation of the `Bucket` interface using a `gocloud.dev/blob.Bucket` instance.

func NewBucket

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

NewBucket returns a new `Bucket` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `BucketInitializationFunc` function used to instantiate the new `Bucket`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterBucket` method.

type BucketInitializationFunc

type BucketInitializationFunc func(ctx context.Context, uri string) (Bucket, error)

BucketInitializationFunc is a function defined by individual bucket package and used to create an instance of that bucket

Jump to

Keyboard shortcuts

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