2021-06-01 18:22:41 +00:00
|
|
|
package blobovniczaconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
2022-06-16 15:07:02 +00:00
|
|
|
boltdbconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/boltdb"
|
2021-06-01 18:22:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config is a wrapper over the config section
|
|
|
|
// which provides access to Blobovnicza configurations.
|
|
|
|
type Config config.Config
|
|
|
|
|
|
|
|
// config defaults
|
|
|
|
const (
|
|
|
|
// SizeDefault is a default limit of estimates of Blobovnicza size.
|
|
|
|
SizeDefault = 1 << 30
|
|
|
|
|
|
|
|
// ShallowDepthDefault is a default shallow dir depth.
|
|
|
|
ShallowDepthDefault = 2
|
|
|
|
|
|
|
|
// ShallowWidthDefault is a default shallow dir width.
|
|
|
|
ShallowWidthDefault = 16
|
|
|
|
|
|
|
|
// OpenedCacheSizeDefault is a default cache size of opened Blobovnicza's.
|
|
|
|
OpenedCacheSizeDefault = 16
|
|
|
|
)
|
|
|
|
|
|
|
|
// From wraps config section into Config.
|
|
|
|
func From(c *config.Config) *Config {
|
|
|
|
return (*Config)(c)
|
|
|
|
}
|
|
|
|
|
2022-07-11 12:34:17 +00:00
|
|
|
// Type returns the storage type.
|
|
|
|
func (x *Config) Type() string {
|
|
|
|
return "blobovnicza"
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// Size returns the value of "size" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns SizeDefault if the value is not a positive number.
|
2021-06-01 18:22:41 +00:00
|
|
|
func (x *Config) Size() uint64 {
|
2021-10-07 16:17:07 +00:00
|
|
|
s := config.SizeInBytesSafe(
|
2021-06-01 18:22:41 +00:00
|
|
|
(*config.Config)(x),
|
|
|
|
"size",
|
|
|
|
)
|
|
|
|
|
|
|
|
if s > 0 {
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
return SizeDefault
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// ShallowDepth returns the value of "depth" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns ShallowDepthDefault if the value is not a positive number.
|
2021-06-01 18:22:41 +00:00
|
|
|
func (x *Config) ShallowDepth() uint64 {
|
|
|
|
d := config.UintSafe(
|
|
|
|
(*config.Config)(x),
|
2021-10-18 14:20:03 +00:00
|
|
|
"depth",
|
2021-06-01 18:22:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if d > 0 {
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
return ShallowDepthDefault
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// ShallowWidth returns the value of "width" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns ShallowWidthDefault if the value is not a positive number.
|
2021-06-01 18:22:41 +00:00
|
|
|
func (x *Config) ShallowWidth() uint64 {
|
|
|
|
d := config.UintSafe(
|
|
|
|
(*config.Config)(x),
|
2021-10-18 14:20:03 +00:00
|
|
|
"width",
|
2021-06-01 18:22:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if d > 0 {
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
return ShallowWidthDefault
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// OpenedCacheSize returns the value of "opened_cache_capacity" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns OpenedCacheSizeDefault if the value is not a positive number.
|
2021-06-01 18:22:41 +00:00
|
|
|
func (x *Config) OpenedCacheSize() int {
|
|
|
|
d := config.IntSafe(
|
|
|
|
(*config.Config)(x),
|
2021-10-18 14:08:01 +00:00
|
|
|
"opened_cache_capacity",
|
2021-06-01 18:22:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if d > 0 {
|
|
|
|
return int(d)
|
|
|
|
}
|
|
|
|
|
|
|
|
return OpenedCacheSizeDefault
|
|
|
|
}
|
2022-06-16 15:07:02 +00:00
|
|
|
|
|
|
|
// BoltDB returns config instance for querying bolt db specific parameters.
|
|
|
|
func (x *Config) BoltDB() *boltdbconfig.Config {
|
|
|
|
return (*boltdbconfig.Config)(x)
|
|
|
|
}
|