[#1627] node: Add tree service to the config framework

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-07-26 12:48:55 +03:00 committed by fyrchik
parent a0fae0443f
commit 8162b27264
3 changed files with 99 additions and 6 deletions

View file

@ -3,13 +3,13 @@ package main
import (
"context"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
treeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/tree"
"github.com/nspcc-dev/neofs-node/pkg/services/tree"
)
func initTreeService(c *cfg) {
sub := c.appCfg.Sub("tree")
if !config.BoolSafe(sub, "enabled") {
treeConfig := treeconfig.Tree(c.appCfg)
if !treeConfig.Enabled() {
c.log.Info("tree service is not enabled, skip initialization")
return
}
@ -20,9 +20,9 @@ func initTreeService(c *cfg) {
tree.WithPrivateKey(&c.key.PrivateKey),
tree.WithLogger(c.log),
tree.WithStorage(c.cfgObject.cfgLocalStorage.localStorage),
tree.WithContainerCacheSize(int(config.IntSafe(sub, "cache_size"))),
tree.WithReplicationChannelCapacity(int(config.IntSafe(sub, "replication_channel_capacity"))),
tree.WithReplicationWorkerCount(int(config.IntSafe(sub, "replication_worker_count"))))
tree.WithContainerCacheSize(treeConfig.CacheSize()),
tree.WithReplicationChannelCapacity(treeConfig.ReplicationChannelCapacity()),
tree.WithReplicationWorkerCount(treeConfig.ReplicationWorkerCount()))
for _, srv := range c.cfgGRPC.servers {
tree.RegisterTreeServiceServer(srv, c.treeService)