Documentation ¶
Index ¶
Constants ¶
const ( Kib = 1 << (10 * (iota + 1)) Mib Gib )
Variables ¶
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 Replicas []Replica }
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, options ...Option) *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.Reader) (*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.
Before a blob is written, the minimum amount of free space must be available on the local disk. If writing the blob consumes more then the available space (free space - minimum free), then this results in an error.
type Option ¶ added in v0.2.3
type Option func(*config)
Option is a function that sets a value in a config.
func WithMinFreeSpace ¶ added in v0.2.3
WithMinFreeSpace seta the minimum amount of free dist space that must remain after writing a blob. If unset or 0 then defaultMinFreeSpace is used. If -1, then no free space checks are performed.
type PassThroughGet ¶ added in v0.2.2
type PassThroughGet interface {
PassGet(http.ResponseWriter, *http.Request, ID)
}