Documentation
¶
Overview ¶
Package blob abstracts away blob storage providers, mostly for testing etc.
Index ¶
- Variables
- type MemoryStore
- func (ms *MemoryStore) Delete(_ context.Context, key string) error
- func (ms *MemoryStore) Get(_ context.Context, key string) (io.ReadCloser, error)
- func (ms *MemoryStore) Put(_ context.Context, key string, r io.Reader) error
- func (ms *MemoryStore) ScanPrefix(ctx context.Context, prefix string) iter.Seq2[*Ref, error]
- type Prefixed
- func (ps *Prefixed) Delete(ctx context.Context, key string) error
- func (ps *Prefixed) Get(ctx context.Context, key string) (io.ReadCloser, error)
- func (ps *Prefixed) Put(ctx context.Context, key string, r io.Reader) error
- func (ps *Prefixed) ScanPrefix(ctx context.Context, prefix string) iter.Seq2[*Ref, error]
- type Ref
- type S3Credentials
- type S3Store
- func (s3s *S3Store) Delete(ctx context.Context, key string) error
- func (s3s *S3Store) Get(ctx context.Context, key string) (io.ReadCloser, error)
- func (s3s *S3Store) Put(ctx context.Context, key string, r io.Reader) error
- func (s3s *S3Store) ScanPrefix(ctx context.Context, prefix string) iter.Seq2[*Ref, error]
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is a sentinel error returned when a blob is not found. ErrNotFound = errors.New("blob: not found") )
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory blob store.
func (*MemoryStore) Get ¶
func (ms *MemoryStore) Get(_ context.Context, key string) (io.ReadCloser, error)
func (*MemoryStore) ScanPrefix ¶
type Prefixed ¶
type Prefixed struct {
// contains filtered or unexported fields
}
PrefixedStore wraps a blob store and prefixes all keys with a given prefix. Essentially, creates a "subdirectory" in the blob store and pretends it's the root.
func NewPrefixed ¶
NewPrefixed creates a new prefixed blob store.
type S3Credentials ¶
type S3Credentials struct { Region string // If unset, defaults to "us-east-1" Endpoint string // If unset, defaults to "https://s3.amazonaws.com" AccessKeyID string SecretAccessKey string }
S3Credentials contains the necessary credentials to connect to an S3-compatible storage provider.
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
S3Store is a blob store backed by an S3-compatible storage provider.
func NewS3Store ¶
func NewS3Store(creds *S3Credentials, bucket string) (*S3Store, error)
NewS3Store creates a new S3 blob store from passed credentials.
type Store ¶
type Store interface { // Get retrieves a blob from the store by its key. // Returns an io.ReadCloser, i.e. caller must close it when done. Get(ctx context.Context, key string) (io.ReadCloser, error) // Put stores a blob in the store under the given key. Put(ctx context.Context, key string, r io.Reader) error // Delete removes a blob from the store by its key. Delete(ctx context.Context, key string) error // ScanPrefix returns an iterator over a prefix of keys. // Will continue iterating until the iterator is exhausted, the // caller indicates it is done by returning false from the callback, // or the context is cancelled. ScanPrefix(ctx context.Context, prefix string) iter.Seq2[*Ref, error] }
Store is a blob storage provider which can be used to store and retrieve blobs of data, identified by a key.