forked from TrueCloudLab/frostfs-node
[#11] Build simple neofs-node application
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
a87fdab324
commit
265c26150d
5 changed files with 140 additions and 3 deletions
11
cmd/neofs-node/config.go
Normal file
11
cmd/neofs-node/config.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type cfg struct {
|
||||||
|
grpcAddr string
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultCfg() *cfg {
|
||||||
|
return &cfg{
|
||||||
|
grpcAddr: ":50501",
|
||||||
|
}
|
||||||
|
}
|
113
cmd/neofs-node/grpc.go
Normal file
113
cmd/neofs-node/grpc.go
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
accounting "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
|
||||||
|
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"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type unimplementedServer struct {
|
||||||
|
accServer
|
||||||
|
cnrServer
|
||||||
|
objServer
|
||||||
|
}
|
||||||
|
|
||||||
|
type accServer struct{}
|
||||||
|
|
||||||
|
type sesServer struct{}
|
||||||
|
|
||||||
|
type cnrServer struct{}
|
||||||
|
|
||||||
|
type objServer struct{}
|
||||||
|
|
||||||
|
func unimplementedErr(srv, call string) error {
|
||||||
|
return errors.Errorf("unimplemented service call %s.%s", srv, call)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*accServer) Balance(context.Context, *accounting.BalanceRequest) (*accounting.BalanceResponse, error) {
|
||||||
|
return nil, unimplementedErr("Accounting", "Balance")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*sesServer) Create(context.Context, *session.CreateRequest) (*session.CreateResponse, error) {
|
||||||
|
return nil, unimplementedErr("Session", "Create")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*cnrServer) Put(context.Context, *container.PutRequest) (*container.PutResponse, error) {
|
||||||
|
return nil, unimplementedErr("Contianer", "Put")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*cnrServer) Delete(context.Context, *container.DeleteRequest) (*container.DeleteResponse, error) {
|
||||||
|
return nil, unimplementedErr("Contianer", "Delete")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*cnrServer) Get(context.Context, *container.GetRequest) (*container.GetResponse, error) {
|
||||||
|
return nil, unimplementedErr("Contianer", "Get")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*cnrServer) List(context.Context, *container.ListRequest) (*container.ListResponse, error) {
|
||||||
|
return nil, unimplementedErr("Contianer", "List")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*cnrServer) SetExtendedACL(context.Context, *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) {
|
||||||
|
return nil, unimplementedErr("Contianer", "SetExtendedACL")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*cnrServer) GetExtendedACL(context.Context, *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) {
|
||||||
|
return nil, unimplementedErr("Contianer", "GetExtendedACL")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) Get(*object.GetRequest, object.ObjectService_GetServer) error {
|
||||||
|
return unimplementedErr("Object", "Get")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) Put(object.ObjectService_PutServer) error {
|
||||||
|
return unimplementedErr("Object", "Put")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) Delete(context.Context, *object.DeleteRequest) (*object.DeleteResponse, error) {
|
||||||
|
return nil, unimplementedErr("Object", "Delete")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) Head(context.Context, *object.HeadRequest) (*object.HeadResponse, error) {
|
||||||
|
return nil, unimplementedErr("Object", "Head")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) Search(*object.SearchRequest, object.ObjectService_SearchServer) error {
|
||||||
|
return unimplementedErr("Object", "Search")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) GetRange(*object.GetRangeRequest, object.ObjectService_GetRangeServer) error {
|
||||||
|
return unimplementedErr("Object", "GetRange")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*objServer) GetRangeHash(context.Context, *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
|
||||||
|
return nil, unimplementedErr("Object", "GetRangeHash")
|
||||||
|
}
|
||||||
|
|
||||||
|
func serveGRPC(c *cfg) error {
|
||||||
|
lis, err := net.Listen("tcp", c.grpcAddr)
|
||||||
|
fatalOnErr(err)
|
||||||
|
|
||||||
|
srv := grpc.NewServer()
|
||||||
|
|
||||||
|
s := new(unimplementedServer)
|
||||||
|
|
||||||
|
accounting.RegisterAccountingServiceServer(srv, s)
|
||||||
|
container.RegisterContainerServiceServer(srv, s)
|
||||||
|
session.RegisterSessionServiceServer(srv, s)
|
||||||
|
object.RegisterObjectServiceServer(srv, s)
|
||||||
|
|
||||||
|
if err := srv.Serve(lis); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
lis.Close()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,10 +1,22 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func fatalOnErr(err error) {
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
c := defaultCfg()
|
||||||
|
|
||||||
|
fatalOnErr(serveGRPC(c))
|
||||||
|
|
||||||
ctx := grace.NewGracefulContext(nil)
|
ctx := grace.NewGracefulContext(nil)
|
||||||
|
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
|
|
7
go.mod
7
go.mod
|
@ -16,9 +16,10 @@ require (
|
||||||
github.com/multiformats/go-multihash v0.0.13
|
github.com/multiformats/go-multihash v0.0.13
|
||||||
github.com/nspcc-dev/hrw v1.0.9
|
github.com/nspcc-dev/hrw v1.0.9
|
||||||
github.com/nspcc-dev/neo-go v0.90.0
|
github.com/nspcc-dev/neo-go v0.90.0
|
||||||
github.com/nspcc-dev/neofs-api-go v1.3.0
|
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200820112910-89e79ebe72b0
|
||||||
github.com/nspcc-dev/neofs-crypto v0.3.0
|
github.com/nspcc-dev/neofs-crypto v0.3.0
|
||||||
github.com/nspcc-dev/netmap v1.7.0
|
github.com/nspcc-dev/netmap v1.7.0
|
||||||
|
github.com/nspcc-dev/tzhash v1.4.0 // indirect
|
||||||
github.com/panjf2000/ants/v2 v2.3.0
|
github.com/panjf2000/ants/v2 v2.3.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.6.0
|
github.com/prometheus/client_golang v1.6.0
|
||||||
|
@ -26,7 +27,7 @@ require (
|
||||||
github.com/spaolacci/murmur3 v1.1.0
|
github.com/spaolacci/murmur3 v1.1.0
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/spf13/viper v1.7.0
|
github.com/spf13/viper v1.7.0
|
||||||
github.com/stretchr/testify v1.5.1
|
github.com/stretchr/testify v1.6.1
|
||||||
github.com/valyala/fasthttp v1.9.0
|
github.com/valyala/fasthttp v1.9.0
|
||||||
go.etcd.io/bbolt v1.3.4
|
go.etcd.io/bbolt v1.3.4
|
||||||
go.uber.org/atomic v1.5.1
|
go.uber.org/atomic v1.5.1
|
||||||
|
@ -41,4 +42,4 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Used for debug reasons
|
// Used for debug reasons
|
||||||
// replace github.com/nspcc-dev/neofs-api-go => ../neofs-api-go
|
replace github.com/nspcc-dev/neofs-api-go => ../neofs-api-go
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
Loading…
Reference in a new issue