From 55148404eed2693125d3c0b5482187cdab91c581 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 21 Sep 2022 08:58:05 +0300 Subject: [PATCH] [#1806] writecache: Use interfaces for blobstor and metabase Signed-off-by: Evgenii Stratonikov --- .../writecache/options.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/local_object_storage/writecache/options.go b/pkg/local_object_storage/writecache/options.go index 12866023..d6cb7567 100644 --- a/pkg/local_object_storage/writecache/options.go +++ b/pkg/local_object_storage/writecache/options.go @@ -4,21 +4,36 @@ import ( "time" "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" + objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" "go.uber.org/zap" ) // Option represents write-cache configuration option. 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 { log *zap.Logger // path is a path to a directory for write-cache. path string // blobstor is the main persistent storage. - blobstor *blobstor.BlobStor + blobstor blob // metabase is the metabase instance. - metabase *meta.DB + metabase metabase // maxObjectSize is the maximum size of the object stored in the write-cache. maxObjectSize uint64 // smallObjectSize is the maximum size of the object stored in the database.