[#11] neofs-node: Improve sources
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
21c750016b
commit
3308fcf56d
5 changed files with 80 additions and 59 deletions
|
@ -1,8 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
container "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
||||
object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
|
||||
session "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
|
||||
containerGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc"
|
||||
objectGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc"
|
||||
sessionGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/session/grpc"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
||||
)
|
||||
|
||||
|
@ -15,11 +22,38 @@ func fatalOnErr(err error) {
|
|||
func main() {
|
||||
c := defaultCfg()
|
||||
|
||||
init_(c)
|
||||
|
||||
bootUp(c)
|
||||
|
||||
wait(c)
|
||||
|
||||
shutdown(c)
|
||||
}
|
||||
|
||||
func init_(c *cfg) {
|
||||
c.ctx = grace.NewGracefulContext(nil)
|
||||
|
||||
serveGRPC(c)
|
||||
initGRPC(c)
|
||||
|
||||
initAccountingService(c)
|
||||
|
||||
container.RegisterContainerServiceServer(c.cfgGRPC.server, containerGRPC.New(new(containerSvc)))
|
||||
session.RegisterSessionServiceServer(c.cfgGRPC.server, sessionGRPC.New(new(sessionSvc)))
|
||||
object.RegisterObjectServiceServer(c.cfgGRPC.server, objectGRPC.New(new(objectSvc)))
|
||||
}
|
||||
|
||||
func bootUp(c *cfg) {
|
||||
serveGRPC(c)
|
||||
}
|
||||
|
||||
func wait(c *cfg) {
|
||||
<-c.ctx.Done()
|
||||
}
|
||||
|
||||
func shutdown(c *cfg) {
|
||||
c.cfgGRPC.server.GracefulStop()
|
||||
fmt.Println("gRPC server stopped")
|
||||
|
||||
c.wg.Wait()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue