forked from TrueCloudLab/frostfs-node
[#9999] shard: Add objectstore opts
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
2fae2cd39c
commit
f57f4b87f7
4 changed files with 72 additions and 0 deletions
|
@ -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),
|
||||
|
|
39
pkg/local_object_storage/objectstore/options.go
Normal file
39
pkg/local_object_storage/objectstore/options.go
Normal file
|
@ -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
|
||||
}
|
||||
}
|
11
pkg/local_object_storage/objectstore/store.go
Normal file
11
pkg/local_object_storage/objectstore/store.go
Normal file
|
@ -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
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue