[#645] config: Resolve funlen linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
588113b7d6
commit
e7c379044f
1 changed files with 82 additions and 63 deletions
|
@ -186,7 +186,7 @@ type subStorageCfg struct {
|
||||||
leafWidth uint64
|
leafWidth uint64
|
||||||
openedCacheSize int
|
openedCacheSize int
|
||||||
|
|
||||||
//badgerstore-specific
|
// badgerstore-specific
|
||||||
indexCacheSize int64
|
indexCacheSize int64
|
||||||
memTablesCount int
|
memTablesCount int
|
||||||
compactorsCount int
|
compactorsCount int
|
||||||
|
@ -812,6 +812,100 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
||||||
for _, sRead := range shCfg.subStorages {
|
for _, sRead := range shCfg.subStorages {
|
||||||
switch sRead.typ {
|
switch sRead.typ {
|
||||||
case blobovniczatree.Type:
|
case blobovniczatree.Type:
|
||||||
|
blobovniczaTreeOpts := c.getBlobovniczaTreeOpts(sRead)
|
||||||
|
ss = append(ss, blobstor.SubStorage{
|
||||||
|
Storage: blobovniczatree.NewBlobovniczaTree(blobovniczaTreeOpts...),
|
||||||
|
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||||
|
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
||||||
|
},
|
||||||
|
})
|
||||||
|
case fstree.Type:
|
||||||
|
fstreeOpts := c.getFSTreeOpts(sRead)
|
||||||
|
ss = append(ss, blobstor.SubStorage{
|
||||||
|
Storage: fstree.New(fstreeOpts...),
|
||||||
|
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
})
|
||||||
|
case blobtree.Type:
|
||||||
|
blobTreeOpts := c.getBlobTreeOpts(sRead)
|
||||||
|
ss = append(ss, blobstor.SubStorage{
|
||||||
|
Storage: blobtree.New(blobTreeOpts...),
|
||||||
|
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||||
|
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
||||||
|
},
|
||||||
|
})
|
||||||
|
case badgerstore.Type:
|
||||||
|
badgerStoreOpts := c.getBadgerStoreOpts(sRead)
|
||||||
|
ss = append(ss, blobstor.SubStorage{
|
||||||
|
Storage: badgerstore.New(badgerStoreOpts...),
|
||||||
|
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||||
|
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
||||||
|
},
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
// should never happen, that has already
|
||||||
|
// been handled: when the config was read
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ss
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cfg) getBadgerStoreOpts(sRead subStorageCfg) []badgerstore.Option {
|
||||||
|
badgerStoreOpts := []badgerstore.Option{
|
||||||
|
badgerstore.WithPath(sRead.path),
|
||||||
|
badgerstore.WithPermissions(sRead.perm),
|
||||||
|
badgerstore.WithCompactorsCount(sRead.compactorsCount),
|
||||||
|
badgerstore.WithGCDiscardRatio(sRead.gcDiscardRatio),
|
||||||
|
badgerstore.WithGCInterval(sRead.gcInterval),
|
||||||
|
badgerstore.WithIndexCacheSize(sRead.indexCacheSize),
|
||||||
|
badgerstore.WithMemTablesCount(sRead.memTablesCount),
|
||||||
|
badgerstore.WithValueLogSize(sRead.valueLogFileSize),
|
||||||
|
}
|
||||||
|
if c.metricsCollector != nil {
|
||||||
|
badgerStoreOpts = append(badgerStoreOpts,
|
||||||
|
badgerstore.WithMetrics(
|
||||||
|
lsmetrics.NewBadgerStoreMetrics(sRead.path, c.metricsCollector.BadgerStoreMetrics())))
|
||||||
|
}
|
||||||
|
return badgerStoreOpts
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cfg) getBlobTreeOpts(sRead subStorageCfg) []blobtree.Option {
|
||||||
|
blobTreeOpts := []blobtree.Option{
|
||||||
|
blobtree.WithPath(sRead.path),
|
||||||
|
blobtree.WithPerm(sRead.perm),
|
||||||
|
blobtree.WithDepth(sRead.depth),
|
||||||
|
blobtree.WithTargetSize(sRead.size),
|
||||||
|
}
|
||||||
|
if c.metricsCollector != nil {
|
||||||
|
blobTreeOpts = append(blobTreeOpts,
|
||||||
|
blobtree.WithMetrics(
|
||||||
|
lsmetrics.NewBlobTreeMetrics(sRead.path, c.metricsCollector.BlobTreeMetrics()),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return blobTreeOpts
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cfg) getFSTreeOpts(sRead subStorageCfg) []fstree.Option {
|
||||||
|
fstreeOpts := []fstree.Option{
|
||||||
|
fstree.WithPath(sRead.path),
|
||||||
|
fstree.WithPerm(sRead.perm),
|
||||||
|
fstree.WithDepth(sRead.depth),
|
||||||
|
fstree.WithNoSync(sRead.noSync),
|
||||||
|
fstree.WithLogger(c.log),
|
||||||
|
}
|
||||||
|
if c.metricsCollector != nil {
|
||||||
|
fstreeOpts = append(fstreeOpts,
|
||||||
|
fstree.WithMetrics(
|
||||||
|
lsmetrics.NewFSTreeMetricsWithoutShardID(sRead.path, c.metricsCollector.FSTree()),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return fstreeOpts
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cfg) getBlobovniczaTreeOpts(sRead subStorageCfg) []blobovniczatree.Option {
|
||||||
blobTreeOpts := []blobovniczatree.Option{
|
blobTreeOpts := []blobovniczatree.Option{
|
||||||
blobovniczatree.WithRootPath(sRead.path),
|
blobovniczatree.WithRootPath(sRead.path),
|
||||||
blobovniczatree.WithPermissions(sRead.perm),
|
blobovniczatree.WithPermissions(sRead.perm),
|
||||||
|
@ -830,82 +924,7 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ss = append(ss, blobstor.SubStorage{
|
return blobTreeOpts
|
||||||
Storage: blobovniczatree.NewBlobovniczaTree(blobTreeOpts...),
|
|
||||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
|
||||||
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
|
||||||
},
|
|
||||||
})
|
|
||||||
case fstree.Type:
|
|
||||||
fstreeOpts := []fstree.Option{
|
|
||||||
fstree.WithPath(sRead.path),
|
|
||||||
fstree.WithPerm(sRead.perm),
|
|
||||||
fstree.WithDepth(sRead.depth),
|
|
||||||
fstree.WithNoSync(sRead.noSync),
|
|
||||||
fstree.WithLogger(c.log),
|
|
||||||
}
|
|
||||||
if c.metricsCollector != nil {
|
|
||||||
fstreeOpts = append(fstreeOpts,
|
|
||||||
fstree.WithMetrics(
|
|
||||||
lsmetrics.NewFSTreeMetricsWithoutShardID(sRead.path, c.metricsCollector.FSTree()),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
ss = append(ss, blobstor.SubStorage{
|
|
||||||
Storage: fstree.New(fstreeOpts...),
|
|
||||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
})
|
|
||||||
case blobtree.Type:
|
|
||||||
blobTreeOpts := []blobtree.Option{
|
|
||||||
blobtree.WithPath(sRead.path),
|
|
||||||
blobtree.WithPerm(sRead.perm),
|
|
||||||
blobtree.WithDepth(sRead.depth),
|
|
||||||
blobtree.WithTargetSize(sRead.size),
|
|
||||||
}
|
|
||||||
if c.metricsCollector != nil {
|
|
||||||
blobTreeOpts = append(blobTreeOpts,
|
|
||||||
blobtree.WithMetrics(
|
|
||||||
lsmetrics.NewBlobTreeMetrics(sRead.path, c.metricsCollector.BlobTreeMetrics()),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
ss = append(ss, blobstor.SubStorage{
|
|
||||||
Storage: blobtree.New(blobTreeOpts...),
|
|
||||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
|
||||||
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
|
||||||
},
|
|
||||||
})
|
|
||||||
case badgerstore.Type:
|
|
||||||
badgerStoreOpts := []badgerstore.Option{
|
|
||||||
badgerstore.WithPath(sRead.path),
|
|
||||||
badgerstore.WithPermissions(sRead.perm),
|
|
||||||
badgerstore.WithCompactorsCount(sRead.compactorsCount),
|
|
||||||
badgerstore.WithGCDiscardRatio(sRead.gcDiscardRatio),
|
|
||||||
badgerstore.WithGCInterval(sRead.gcInterval),
|
|
||||||
badgerstore.WithIndexCacheSize(sRead.indexCacheSize),
|
|
||||||
badgerstore.WithMemTablesCount(sRead.memTablesCount),
|
|
||||||
badgerstore.WithValueLogSize(sRead.valueLogFileSize),
|
|
||||||
}
|
|
||||||
if c.metricsCollector != nil {
|
|
||||||
badgerStoreOpts = append(badgerStoreOpts,
|
|
||||||
badgerstore.WithMetrics(
|
|
||||||
lsmetrics.NewBadgerStoreMetrics(sRead.path, c.metricsCollector.BadgerStoreMetrics())))
|
|
||||||
}
|
|
||||||
ss = append(ss, blobstor.SubStorage{
|
|
||||||
Storage: badgerstore.New(badgerStoreOpts...),
|
|
||||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
|
||||||
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
|
||||||
},
|
|
||||||
})
|
|
||||||
default:
|
|
||||||
// should never happen, that has already
|
|
||||||
// been handled: when the config was read
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ss
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID {
|
func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID {
|
||||||
|
|
Loading…
Add table
Reference in a new issue