Documentation
¶
Overview ¶
Package writecache implements write-cache for objects.
Write-cache uses file system tree for storing objects.
Flushing from the writecache to the main storage is done in the background.
Index ¶
- Variables
- type Cache
- type Info
- type Metabase
- type ObjectStatus
- type Option
- func WithBlobstor(bs *blobstor.BlobStor) Option
- func WithFlushWorkersCount(c int) Option
- func WithLogger(log *zap.Logger) Option
- func WithMaxCacheSize(sz uint64) Option
- func WithMaxObjectSize(sz uint64) Option
- func WithMetabase(db Metabase) Option
- func WithNoSync(noSync bool) Option
- func WithPath(path string) Option
- func WithReportErrorFunc(f func(string, error)) Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBigObject is returned when object is too big to be placed in cache. ErrBigObject = errors.New("too big object") // ErrOutOfSpace is returned when there is no space left to put a new object. ErrOutOfSpace = errors.New("no space left in the write cache") )
var ErrReadOnly = logicerr.New("write-cache is in read-only mode")
ErrReadOnly is returned when Put/Write is performed in a read-only mode.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
Get(address oid.Address) (*object.Object, error)
// GetBytes reads object from the Cache by address into memory buffer in a
// canonical NeoFS binary format. Returns [apistatus.ObjectNotFound] if object
// is missing.
GetBytes(oid.Address) ([]byte, error)
Head(oid.Address) (*object.Object, error)
// Delete removes object referenced by the given oid.Address from the
// Cache. Returns any error encountered that prevented the object to be
// removed.
//
// Returns apistatus.ObjectNotFound if object is missing in the Cache.
// Returns ErrReadOnly if the Cache is currently in the read-only mode.
Delete(oid.Address) error
Iterate(func(oid.Address, []byte) error, bool) error
Put(oid.Address, *object.Object, []byte) error
SetMode(mode.Mode) error
SetLogger(*zap.Logger)
DumpInfo() Info
Flush(bool) error
Init() error
Open(readOnly bool) error
Close() error
ObjectStatus(address oid.Address) (ObjectStatus, error)
}
Cache represents write-cache for objects.
type Info ¶ added in v0.27.2
type Info struct {
// Full path to the write-cache.
Path string
}
Info groups the information about write-cache.
type Metabase ¶ added in v0.44.0
type Metabase interface {
Exists(addr oid.Address, ignoreExpiration bool) (bool, error)
StorageID(addr oid.Address) ([]byte, error)
UpdateStorageID(addr oid.Address, newID []byte) error
Put(obj *objectSDK.Object, storageID []byte, binHeader []byte) error
}
Metabase is an interface to metabase sufficient for writecache to operate.
type ObjectStatus ¶ added in v0.39.0
type ObjectStatus struct {
PathFSTree string
}
ObjectStatus represents the status of the object in the Writecache.
type Option ¶
type Option func(*options)
Option represents write-cache configuration option.
func WithBlobstor ¶
WithBlobstor sets main object storage.
func WithFlushWorkersCount ¶
WithFlushWorkersCount sets number of workers to flushing objects in parallel.
func WithMaxCacheSize ¶ added in v0.25.0
WithMaxCacheSize sets maximum write-cache size in bytes.
func WithMaxObjectSize ¶
WithMaxObjectSize sets maximum object size to be stored in write-cache.
func WithNoSync ¶ added in v0.36.0
WithNoSync sets an option to allow returning to caller on PUT before write is persisted.
func WithReportErrorFunc ¶ added in v0.36.0
WithReportErrorFunc sets error reporting function.