diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 427620a70..1b17fc1ed 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -36,6 +36,7 @@ import ( netmapCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine" lsmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metrics" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/objectstore" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard" shardmode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" @@ -823,8 +824,19 @@ func (c *cfg) getPiloramaOpts(shCfg shardCfg) []pilorama.Option { return piloramaOpts } +func (c *cfg) getObjectStoreOpts(shCfg shardCfg) []objectstore.Option { + var result []objectstore.Option + result = append(result, + objectstore.WithBlobPath(shCfg.objectStoreCfg.blobPath), + objectstore.WithMetaPath(shCfg.objectStoreCfg.metaPath), + objectstore.WithWalPath(shCfg.objectStoreCfg.walPath), + ) + return result +} + func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID { piloramaOpts := c.getPiloramaOpts(shCfg) + objectstoreOpts := c.getObjectStoreOpts(shCfg) var sh shardOptsWithID sh.configID = shCfg.id() @@ -832,6 +844,7 @@ func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID { shard.WithLogger(c.log), shard.WithMode(shCfg.mode), shard.WithPiloramaOptions(piloramaOpts...), + shard.WithObjectStoreOptions(objectstoreOpts...), shard.WithRemoverBatchSize(shCfg.gcCfg.removerBatchSize), shard.WithGCRemoverSleepInterval(shCfg.gcCfg.removerSleepInterval), shard.WithExpiredCollectorBatchSize(shCfg.gcCfg.expiredCollectorBatchSize), diff --git a/pkg/local_object_storage/objectstore/options.go b/pkg/local_object_storage/objectstore/options.go new file mode 100644 index 000000000..8a4684c6f --- /dev/null +++ b/pkg/local_object_storage/objectstore/options.go @@ -0,0 +1,39 @@ +package objectstore + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" + "go.uber.org/zap" +) + +type config struct { + logger *logger.Logger + walPath string + blobPath string + metaPath string +} + +type Option func(*config) + +func defaultCfg() *config { + return &config{ + logger: logger.NewLoggerWrapper(zap.L()), + } +} + +func WithMetaPath(path string) Option { + return func(c *config) { + c.metaPath = path + } +} + +func WithBlobPath(path string) Option { + return func(c *config) { + c.blobPath = path + } +} + +func WithWalPath(path string) Option { + return func(c *config) { + c.walPath = path + } +} diff --git a/pkg/local_object_storage/objectstore/store.go b/pkg/local_object_storage/objectstore/store.go new file mode 100644 index 000000000..579ca179a --- /dev/null +++ b/pkg/local_object_storage/objectstore/store.go @@ -0,0 +1,11 @@ +package objectstore + +type ObjectStore struct{} + +func New(opts ...Option) (*ObjectStore, error) { + cfg := defaultCfg() + for _, opt := range opts { + opt(cfg) + } + return &ObjectStore{}, nil +} diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index 1eb7f14d0..ca19cee3d 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -10,6 +10,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor" meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/objectstore" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache" @@ -78,6 +79,8 @@ type cfg struct { piloramaOpts []pilorama.Option + objectStoreOpts []objectstore.Option + log *logger.Logger gcCfg gcCfg @@ -197,6 +200,12 @@ func WithPiloramaOptions(opts ...pilorama.Option) Option { } } +func WithObjectStoreOptions(opts ...objectstore.Option) Option { + return func(c *cfg) { + c.objectStoreOpts = opts + } +} + // WithLogger returns option to set Shard's logger. func WithLogger(l *logger.Logger) Option { return func(c *cfg) {