Documentation ¶
Index ¶
- Constants
- Variables
- type Dir
- func (dir *Dir) Commit(ctx context.Context, file *os.File, ref storage.BlobRef, ...) (err error)
- func (dir *Dir) CreateTemporaryFile(ctx context.Context, prealloc int64) (_ *os.File, err error)
- func (dir *Dir) Delete(ctx context.Context, ref storage.BlobRef) (err error)
- func (dir *Dir) DeleteTemporary(ctx context.Context, file *os.File) (err error)
- func (dir *Dir) GarbageCollect(ctx context.Context) (err error)
- func (dir *Dir) Info() (DiskInfo, error)
- func (dir *Dir) ListNamespaces(ctx context.Context) (ids [][]byte, err error)
- func (dir *Dir) Open(ctx context.Context, ref storage.BlobRef) (_ *os.File, _ storage.FormatVersion, err error)
- func (dir *Dir) OpenWithStorageFormat(ctx context.Context, blobRef storage.BlobRef, formatVer storage.FormatVersion) (_ *os.File, err error)
- func (dir *Dir) Path() string
- func (dir *Dir) Stat(ctx context.Context, ref storage.BlobRef) (_ storage.BlobInfo, err error)
- func (dir *Dir) StatWithStorageFormat(ctx context.Context, ref storage.BlobRef, formatVer storage.FormatVersion) (_ storage.BlobInfo, err error)
- func (dir *Dir) WalkNamespace(ctx context.Context, namespace []byte, walkFunc func(storage.BlobInfo) error) (err error)
- type DiskInfo
- type Store
- func (store *Store) Close() error
- func (store *Store) Create(ctx context.Context, ref storage.BlobRef, size int64) (_ storage.BlobWriter, err error)
- func (store *Store) Delete(ctx context.Context, ref storage.BlobRef) (err error)
- func (store *Store) FreeSpace() (int64, error)
- func (store *Store) GarbageCollect(ctx context.Context) (err error)
- func (store *Store) ListNamespaces(ctx context.Context) (ids [][]byte, err error)
- func (store *Store) Open(ctx context.Context, ref storage.BlobRef) (_ storage.BlobReader, err error)
- func (store *Store) OpenWithStorageFormat(ctx context.Context, blobRef storage.BlobRef, formatVer storage.FormatVersion) (_ storage.BlobReader, err error)
- func (store *Store) SpaceUsed(ctx context.Context) (space int64, err error)
- func (store *Store) SpaceUsedInNamespace(ctx context.Context, namespace []byte) (int64, error)
- func (store *Store) Stat(ctx context.Context, ref storage.BlobRef) (_ storage.BlobInfo, err error)
- func (store *Store) StatWithStorageFormat(ctx context.Context, ref storage.BlobRef, formatVer storage.FormatVersion) (_ storage.BlobInfo, err error)
- func (store *Store) TestCreateV0(ctx context.Context, ref storage.BlobRef) (_ storage.BlobWriter, err error)
- func (store *Store) WalkNamespace(ctx context.Context, namespace []byte, walkFunc func(storage.BlobInfo) error) (err error)
- type StoreForTest
Constants ¶
const ( // FormatV0 is the identifier for storage format v0, which also corresponds to an absence of // format version information. FormatV0 storage.FormatVersion = 0 // FormatV1 is the identifier for storage format v1 FormatV1 storage.FormatVersion = 1 )
const ( // MaxFormatVersionSupported is the highest supported storage format version for reading, and // the only supported storage format version for writing. If stored blobs claim a higher // storage format version than this, or a caller requests _writing_ a storage format version // which is not this, this software will not know how to perform the read or write and an error // will be returned. MaxFormatVersionSupported = FormatV1 // MinFormatVersionSupported is the lowest supported storage format version for reading. If // stored blobs claim a lower storage format version than this, this software will not know how // to perform the read and an error will be returned. MinFormatVersionSupported = FormatV0 )
Variables ¶
var ( // Error is the default filestore error class Error = errs.Class("filestore error") )
Functions ¶
This section is empty.
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir represents single folder for storing blobs
func (*Dir) Commit ¶
func (dir *Dir) Commit(ctx context.Context, file *os.File, ref storage.BlobRef, formatVersion storage.FormatVersion) (err error)
Commit commits the temporary file to permanent storage.
func (*Dir) CreateTemporaryFile ¶
CreateTemporaryFile creates a preallocated temporary file in the temp directory prealloc preallocates file to make writing faster
func (*Dir) Delete ¶
Delete deletes blobs with the specified ref (in all supported storage formats).
func (*Dir) DeleteTemporary ¶
DeleteTemporary deletes a temporary file
func (*Dir) GarbageCollect ¶
GarbageCollect collects files that are pending deletion.
func (*Dir) ListNamespaces ¶ added in v0.18.0
ListNamespaces finds all known namespace IDs in use in local storage. They are not guaranteed to contain any blobs.
func (*Dir) Open ¶
func (dir *Dir) Open(ctx context.Context, ref storage.BlobRef) (_ *os.File, _ storage.FormatVersion, err error)
Open opens the file with the specified ref. It may need to check in more than one location in order to find the blob, if it was stored with an older version of the storage node software. In cases where the storage format version of a blob is already known, OpenWithStorageFormat() will generally be a better choice.
func (*Dir) OpenWithStorageFormat ¶ added in v0.18.0
func (dir *Dir) OpenWithStorageFormat(ctx context.Context, blobRef storage.BlobRef, formatVer storage.FormatVersion) (_ *os.File, err error)
OpenWithStorageFormat opens an already-located blob file with a known storage format version, which avoids the potential need to search through multiple storage formats to find the blob.
func (*Dir) Stat ¶ added in v0.18.0
Stat looks up disk metadata on the blob file. It may need to check in more than one location in order to find the blob, if it was stored with an older version of the storage node software. In cases where the storage format version of a blob is already known, StatWithStorageFormat() will generally be a better choice.
func (*Dir) StatWithStorageFormat ¶ added in v0.18.0
func (dir *Dir) StatWithStorageFormat(ctx context.Context, ref storage.BlobRef, formatVer storage.FormatVersion) (_ storage.BlobInfo, err error)
StatWithStorageFormat looks up disk metadata on the blob file with the given storage format version. This avoids the need for checking for the file in multiple different storage format types.
func (*Dir) WalkNamespace ¶ added in v0.18.0
func (dir *Dir) WalkNamespace(ctx context.Context, namespace []byte, walkFunc func(storage.BlobInfo) error) (err error)
WalkNamespace executes walkFunc for each locally stored blob, stored with storage format V1 or greater, in the given namespace. If walkFunc returns a non-nil error, WalkNamespace will stop iterating and return the error immediately. The ctx parameter is intended specifically to allow canceling iteration early.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements a blob store
func (*Store) Create ¶
func (store *Store) Create(ctx context.Context, ref storage.BlobRef, size int64) (_ storage.BlobWriter, err error)
Create creates a new blob that can be written optionally takes a size argument for performance improvements, -1 is unknown size
func (*Store) GarbageCollect ¶
GarbageCollect tries to delete any files that haven't yet been deleted
func (*Store) ListNamespaces ¶ added in v0.18.0
ListNamespaces finds all known namespace IDs in use in local storage. They are not guaranteed to contain any blobs.
func (*Store) Open ¶
func (store *Store) Open(ctx context.Context, ref storage.BlobRef) (_ storage.BlobReader, err error)
Open loads blob with the specified hash
func (*Store) OpenWithStorageFormat ¶ added in v0.18.0
func (store *Store) OpenWithStorageFormat(ctx context.Context, blobRef storage.BlobRef, formatVer storage.FormatVersion) (_ storage.BlobReader, err error)
OpenWithStorageFormat loads the already-located blob, avoiding the potential need to check multiple storage formats to find the blob.
func (*Store) SpaceUsed ¶ added in v0.18.0
SpaceUsed adds up the space used in all namespaces for blob storage
func (*Store) SpaceUsedInNamespace ¶ added in v0.18.0
SpaceUsedInNamespace adds up how much is used in the given namespace for blob storage
func (*Store) StatWithStorageFormat ¶ added in v0.18.0
func (store *Store) StatWithStorageFormat(ctx context.Context, ref storage.BlobRef, formatVer storage.FormatVersion) (_ storage.BlobInfo, err error)
StatWithStorageFormat looks up disk metadata on the blob file with the given storage format version
func (*Store) TestCreateV0 ¶ added in v0.18.0
func (store *Store) TestCreateV0(ctx context.Context, ref storage.BlobRef) (_ storage.BlobWriter, err error)
TestCreateV0 creates a new V0 blob that can be written. This is only appropriate in test situations.
func (*Store) WalkNamespace ¶ added in v0.18.0
func (store *Store) WalkNamespace(ctx context.Context, namespace []byte, walkFunc func(storage.BlobInfo) error) (err error)
WalkNamespace executes walkFunc for each locally stored blob in the given namespace. If walkFunc returns a non-nil error, WalkNamespace will stop iterating and return the error immediately. The ctx parameter is intended specifically to allow canceling iteration early.
type StoreForTest ¶ added in v0.18.0
type StoreForTest struct {
*Store
}
StoreForTest is a wrapper for Store that also allows writing new V0 blobs (in order to test situations involving those)