2021-06-01 18:22:41 +00:00
|
|
|
package blobovniczaconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Size returns value of "size" config parameter.
|
|
|
|
//
|
|
|
|
// Returns SizeDefault if value is not a positive number.
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:20:03 +00:00
|
|
|
// ShallowDepth returns value of "depth" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
|
|
|
// Returns ShallowDepthDefault if value is not a positive number.
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:20:03 +00:00
|
|
|
// ShallowWidth returns value of "width" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
|
|
|
// Returns ShallowWidthDefault if value is not a positive number.
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:08:01 +00:00
|
|
|
// OpenedCacheSize returns value of "opened_cache_capacity" config parameter.
|
2021-06-01 18:22:41 +00:00
|
|
|
//
|
|
|
|
// Returns OpenedCacheSizeDefault if value is not a positive number.
|
|
|
|
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
|
|
|
|
}
|