[#70] cmd/neofs-node: Start asynchronous workers on app launch

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2020-10-03 12:57:02 +03:00 committed by Alex Vanin
parent 2b16edebc9
commit 9a604a50b9
3 changed files with 23 additions and 0 deletions

View File

@ -105,6 +105,8 @@ type cfg struct {
cfgObject cfgObject
profiler profiler.Profiler
workers []worker
}
type cfgGRPC struct {

View File

@ -44,6 +44,7 @@ func bootUp(c *cfg) {
serveProfiler(c)
serveGRPC(c)
bootstrapNode(c)
startWorkers(c)
}
func wait(c *cfg) {

View File

@ -0,0 +1,20 @@
package main
import (
"context"
)
type worker interface {
Run(context.Context)
}
func startWorkers(c *cfg) {
for _, wrk := range c.workers {
c.wg.Add(1)
go func() {
wrk.Run(c.ctx)
c.wg.Done()
}()
}
}