2022-04-22 13:30:20 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-07-18 10:16:23 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
2022-04-22 13:30:20 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/tree"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initTreeService(c *cfg) {
|
2022-07-19 08:03:13 +00:00
|
|
|
sub := c.appCfg.Sub("tree")
|
|
|
|
if !config.BoolSafe(sub, "enabled") {
|
2022-07-18 10:16:23 +00:00
|
|
|
c.log.Info("tree service is not enabled, skip initialization")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-16 16:31:50 +00:00
|
|
|
c.treeService = tree.New(
|
2022-04-22 13:30:20 +00:00
|
|
|
tree.WithContainerSource(c.cfgObject.cnrSource),
|
|
|
|
tree.WithNetmapSource(c.netMapSource),
|
|
|
|
tree.WithPrivateKey(&c.key.PrivateKey),
|
|
|
|
tree.WithLogger(c.log),
|
2022-07-19 08:03:13 +00:00
|
|
|
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"))))
|
2022-04-22 13:30:20 +00:00
|
|
|
|
2022-05-06 11:58:36 +00:00
|
|
|
for _, srv := range c.cfgGRPC.servers {
|
2022-05-16 16:31:50 +00:00
|
|
|
tree.RegisterTreeServiceServer(srv, c.treeService)
|
2022-05-06 11:58:36 +00:00
|
|
|
}
|
2022-04-22 13:30:20 +00:00
|
|
|
|
|
|
|
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
|
2022-05-16 16:31:50 +00:00
|
|
|
c.treeService.Start(ctx)
|
2022-04-22 13:30:20 +00:00
|
|
|
}))
|
2022-05-06 11:58:36 +00:00
|
|
|
|
2022-05-16 16:31:50 +00:00
|
|
|
c.onShutdown(c.treeService.Shutdown)
|
2022-04-22 13:30:20 +00:00
|
|
|
}
|