Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// ContentID is the hash of the actual content stored on disk.
ContentID contenthash.Hash `json:"contentID"`
// Size is the actual size of the content stored on disk.
Size int64 `json:"size"`
}
Entry is used to map an ID to a content on disk. There are two IDs involved, firstly the id of the object and secondly the id of the content stored on disk.
type FilesystemStorageBackend ¶
type FilesystemStorageBackend struct {
// contains filtered or unexported fields
}
FilesystemStorageBackend is a storage backend that stores objects on the local filesystem.
It is safe for multiple processes on a single machine to use the same directory in a local filesystem simultaneously. They will coordinate using operating system file locks and may duplicate effort but will not corrupt the data.
However, it is NOT safe for multiple processes on different machines to share a storage directory (for example, if the directory were stored in a network filesystem). File locking is notoriously unreliable in network file systems.
func NewFilesystemStorageBackend ¶
func NewFilesystemStorageBackend(dir string, opts *FilesystemStorageBackendOpts) (*FilesystemStorageBackend, error)
NewFilesystemStorageBackend creates a new filesystem storage backend.
func (*FilesystemStorageBackend) Delete ¶
func (s *FilesystemStorageBackend) Delete(id contenthash.Hash)
Delete removes an object from the storage (if it exists).
func (*FilesystemStorageBackend) Get ¶
func (s *FilesystemStorageBackend) Get(id contenthash.Hash) (io.ReadCloser, error)
Get retrieves an object from storage.
func (*FilesystemStorageBackend) Put ¶
func (s *FilesystemStorageBackend) Put(id contenthash.Hash, r io.ReadSeeker) error
Put adds an object to the storage.
type FilesystemStorageBackendOpts ¶
type FilesystemStorageBackendOpts struct {
// NoSync disables fsync() calls after writing files.
// This will increase performance but may lead to data loss in the event
// of a system crash.
NoSync bool
}
FilesystemStorageBackendOpts can be used to configure the behavior of the filesystem storage backend.
type StorageBackend ¶
type StorageBackend interface {
// Get retrieves an object from storage.
Get(id contenthash.Hash) (io.ReadCloser, error)
// Put adds an object to the storage.
Put(id contenthash.Hash, r io.ReadSeeker) error
// Delete removes an object from the storage (if it exists).
Delete(id contenthash.Hash)
}