Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrBlobTooLarge = errors.New("blob size exceeds the maximum allowed") ErrBlobNotFound = errors.New("no blob is found with given ID") )
Functions ¶
This section is empty.
Types ¶
type Descriptor ¶
type Descriptor struct { // ID is the blob identifier. ID ID // Size is the size of blob in bytes. Size uint64 // ModificationTime is the latest time at which the blob was modified. ModificationTime time.Time Status *Status }
Descriptor describes a created blob.
type ID ¶
ID uniquely identifies a blob.
type LocalStore ¶
type LocalStore struct {
// contains filtered or unexported fields
}
LocalStore is a Store that stores blobs as flat files in a configured directory. Blobs are stored as flat files, named by their ID with .bin extension. This store is used primarily for testing purposes.
func NewLocalStore ¶
func NewLocalStore(dir string) *LocalStore
NewLocalStore instantiates a new LocalStore and uses the given dir as the place to store blobs. Blobs are stored as flat files, named by their ID with .bin extension.
func (*LocalStore) Describe ¶
func (l *LocalStore) Describe(ctx context.Context, id ID) (*Descriptor, error)
Describe gets the description of the blob for the given id. If no blob is found for the given id, ErrBlobNotFound is returned.
func (*LocalStore) Dir ¶
func (l *LocalStore) Dir() string
Dir returns the local directory path used by the store.
func (*LocalStore) Get ¶
func (l *LocalStore) Get(_ context.Context, id ID) (io.ReadSeekCloser, error)
Get Retrieves the content of blob. If no blob is found for the given id, ErrBlobNotFound is returned.
func (*LocalStore) Put ¶
func (l *LocalStore) Put(_ context.Context, reader io.ReadCloser) (*Descriptor, error)
Put reads the given reader fully and stores its content in the store directory as flat files. The reader content is first stored in a temporary directory and upon successful storage is moved to the store directory. The Descriptor.ModificationTime is set to the modification date of the file that corresponds to the content. The Descriptor.ID is randomly generated; see NewID.
type Store ¶
type Store interface { Put(context.Context, io.ReadCloser) (*Descriptor, error) Describe(context.Context, ID) (*Descriptor, error) Get(context.Context, ID) (io.ReadSeekCloser, error) }