[#1806] writecache: Use interfaces for blobstor and metabase

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-09-21 08:58:05 +03:00 committed by fyrchik
parent 36ab1a2472
commit 55148404ee

View file

@ -4,21 +4,36 @@ import (
"time" "time"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"go.uber.org/zap" "go.uber.org/zap"
) )
// Option represents write-cache configuration option. // Option represents write-cache configuration option.
type Option func(*options) type Option func(*options)
// meta is an interface for a metabase.
type metabase interface {
Put(meta.PutPrm) (meta.PutRes, error)
Exists(meta.ExistsPrm) (meta.ExistsRes, error)
}
// blob is an interface for the blobstor.
type blob interface {
Put(common.PutPrm) (common.PutRes, error)
NeedsCompression(obj *objectSDK.Object) bool
Exists(res common.ExistsPrm) (common.ExistsRes, error)
}
type options struct { type options struct {
log *zap.Logger log *zap.Logger
// path is a path to a directory for write-cache. // path is a path to a directory for write-cache.
path string path string
// blobstor is the main persistent storage. // blobstor is the main persistent storage.
blobstor *blobstor.BlobStor blobstor blob
// metabase is the metabase instance. // metabase is the metabase instance.
metabase *meta.DB metabase metabase
// maxObjectSize is the maximum size of the object stored in the write-cache. // maxObjectSize is the maximum size of the object stored in the write-cache.
maxObjectSize uint64 maxObjectSize uint64
// smallObjectSize is the maximum size of the object stored in the database. // smallObjectSize is the maximum size of the object stored in the database.