2021-06-01 18:22:41 +00:00
|
|
|
package blobstorconfig
|
|
|
|
|
|
|
|
import (
|
2022-07-11 12:34:17 +00:00
|
|
|
"strconv"
|
2021-06-01 18:22:41 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
2022-07-11 12:34:17 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor/storage"
|
2022-09-20 12:42:56 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/blobovniczatree"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
2021-06-01 18:22:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config is a wrapper over the config section
|
|
|
|
// which provides access to BlobStor configurations.
|
|
|
|
type Config config.Config
|
|
|
|
|
|
|
|
// From wraps config section into Config.
|
|
|
|
func From(c *config.Config) *Config {
|
|
|
|
return (*Config)(c)
|
|
|
|
}
|
|
|
|
|
2022-07-11 12:34:17 +00:00
|
|
|
// Storages returns the value of storage subcomponents.
|
|
|
|
func (x *Config) Storages() []*storage.Config {
|
|
|
|
var ss []*storage.Config
|
|
|
|
for i := 0; ; i++ {
|
|
|
|
typ := config.String(
|
|
|
|
(*config.Config)(x),
|
|
|
|
strconv.Itoa(i)+".type")
|
|
|
|
switch typ {
|
|
|
|
case "":
|
|
|
|
return ss
|
2022-09-20 12:42:56 +00:00
|
|
|
case fstree.Type, blobovniczatree.Type:
|
2022-07-11 12:34:17 +00:00
|
|
|
sub := storage.From((*config.Config)(x).Sub(strconv.Itoa(i)))
|
|
|
|
ss = append(ss, sub)
|
|
|
|
default:
|
|
|
|
panic("invalid type")
|
|
|
|
}
|
2021-06-01 18:22:41 +00:00
|
|
|
}
|
|
|
|
}
|