backend

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Apache-2.0, BSD-3-Clause, MPL-2.0 Imports: 10 Imported by: 0

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 hashes involved, firstly the hash of the object and secondly the hash 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

Delete removes an object from the storage (if it exists).

func (*FilesystemStorageBackend) Get

Get retrieves an object from storage.

func (*FilesystemStorageBackend) Put

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)
}

Jump to

Keyboard shortcuts

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