[#1523] local_object_storage: Move blobovnicza tree to a separate package
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
5139dc9864
commit
b621f5983a
30 changed files with 758 additions and 538 deletions
96
pkg/local_object_storage/blobstor/blobovniczatree/option.go
Normal file
96
pkg/local_object_storage/blobstor/blobovniczatree/option.go
Normal file
|
@ -0,0 +1,96 @@
|
|||
package blobovniczatree
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/compression"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type cfg struct {
|
||||
log *zap.Logger
|
||||
perm fs.FileMode
|
||||
readOnly bool
|
||||
rootPath string
|
||||
openedCacheSize int
|
||||
blzShallowDepth uint64
|
||||
blzShallowWidth uint64
|
||||
*compression.CConfig
|
||||
blzOpts []blobovnicza.Option
|
||||
}
|
||||
|
||||
type Option func(*cfg)
|
||||
|
||||
const (
|
||||
defaultPerm = 0700
|
||||
defaultOpenedCacheSize = 50
|
||||
defaultBlzShallowDepth = 2
|
||||
defaultBlzShallowWidth = 16
|
||||
)
|
||||
|
||||
func initConfig(c *cfg) {
|
||||
*c = cfg{
|
||||
log: zap.L(),
|
||||
perm: defaultPerm,
|
||||
openedCacheSize: defaultOpenedCacheSize,
|
||||
blzShallowDepth: defaultBlzShallowDepth,
|
||||
blzShallowWidth: defaultBlzShallowWidth,
|
||||
CConfig: new(compression.CConfig),
|
||||
}
|
||||
}
|
||||
|
||||
func WithLogger(l *zap.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.log = l
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(l))
|
||||
}
|
||||
}
|
||||
|
||||
func WithPermissions(perm fs.FileMode) Option {
|
||||
return func(c *cfg) {
|
||||
c.perm = perm
|
||||
}
|
||||
}
|
||||
|
||||
func WithCompressionConfig(cc *compression.CConfig) Option {
|
||||
return func(c *cfg) {
|
||||
c.CConfig = cc
|
||||
}
|
||||
}
|
||||
|
||||
func WithBlobovniczaShallowWidth(width uint64) Option {
|
||||
return func(c *cfg) {
|
||||
c.blzShallowWidth = width
|
||||
}
|
||||
}
|
||||
|
||||
func WithBlobovniczaShallowDepth(depth uint64) Option {
|
||||
return func(c *cfg) {
|
||||
c.blzShallowDepth = depth
|
||||
}
|
||||
}
|
||||
|
||||
func WithRootPath(p string) Option {
|
||||
return func(c *cfg) {
|
||||
c.rootPath = p
|
||||
}
|
||||
}
|
||||
|
||||
func WithBlobovniczaSize(sz uint64) Option {
|
||||
return func(c *cfg) {
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithFullSizeLimit(sz))
|
||||
}
|
||||
}
|
||||
|
||||
func WithOpenedCacheSize(sz int) Option {
|
||||
return func(c *cfg) {
|
||||
c.openedCacheSize = sz
|
||||
}
|
||||
}
|
||||
|
||||
func WithObjectSizeLimit(sz uint64) Option {
|
||||
return func(c *cfg) {
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithObjectSizeLimit(sz))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue