[#425] services: Define service interfaces that was removed from API lib

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-03-15 13:53:08 +03:00 committed by Alex Vanin
parent e6f945e61d
commit 718a2fad26
29 changed files with 107 additions and 42 deletions

View file

@ -125,7 +125,7 @@ func initContainerService(c *cfg) {
c.key,
containerService.NewResponseService(
&usedSpaceService{
Service: containerService.NewExecutionService(containerMorph.NewExecutor(cnrClient)),
Server: containerService.NewExecutionService(containerMorph.NewExecutor(cnrClient)),
loadWriterProvider: loadRouter,
loadPlacementBuilder: loadPlacementBuilder,
routeBuilder: routeBuilder,
@ -341,7 +341,7 @@ func (d *localStorageLoad) Iterate(f loadcontroller.UsedSpaceFilter, h loadcontr
}
type usedSpaceService struct {
containerV2.Service
containerService.Server
loadWriterProvider loadcontroller.WriterProvider

View file

@ -61,7 +61,7 @@ func (c *cfg) MaxObjectSize() uint64 {
return sz
}
func (s *objectSvc) Put(ctx context.Context) (object.PutObjectStreamer, error) {
func (s *objectSvc) Put(ctx context.Context) (objectService.PutObjectStream, error) {
return s.put.Put(ctx)
}

View file

@ -5,16 +5,17 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
accountingGRPC "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
accountingsvc "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
)
// Server wraps NeoFS API Accounting service and
// provides gRPC Accounting service server interface.
type Server struct {
srv accounting.Service
srv accountingsvc.Server
}
// New creates, initializes and returns Server instance.
func New(c accounting.Service) *Server {
func New(c accountingsvc.Server) *Server {
return &Server{
srv: c,
}

View file

@ -5,16 +5,17 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/container"
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
containersvc "github.com/nspcc-dev/neofs-node/pkg/services/container"
)
// Server wraps NeoFS API Container service and
// provides gRPC Container service server interface.
type Server struct {
srv container.Service
srv containersvc.Server
}
// New creates, initializes and returns Server instance.
func New(c container.Service) *Server {
func New(c containersvc.Server) *Server {
return &Server{
srv: c,
}

View file

@ -5,16 +5,17 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
netmapsvc "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
)
// Server wraps NeoFS API Netmap service and
// provides gRPC Netmap service server interface.
type Server struct {
srv netmap.Service
srv netmapsvc.Server
}
// New creates, initializes and returns Server instance.
func New(c netmap.Service) *Server {
func New(c netmapsvc.Server) *Server {
return &Server{
srv: c,
}

View file

@ -5,16 +5,17 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/session"
sessionGRPC "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
sessionsvc "github.com/nspcc-dev/neofs-node/pkg/services/session"
)
// Server wraps NeoFS API Session service and
// provides gRPC Session service server interface.
type Server struct {
srv session.Service
srv sessionsvc.Server
}
// New creates, initializes and returns Server instance.
func New(c session.Service) *Server {
func New(c sessionsvc.Server) *Server {
return &Server{
srv: c,
}

View file

@ -16,7 +16,7 @@ type executorSvc struct {
}
// NewExecutionService wraps ServiceExecutor and returns Accounting Service interface.
func NewExecutionService(exec ServiceExecutor) accounting.Service {
func NewExecutionService(exec ServiceExecutor) Server {
return &executorSvc{
exec: exec,
}

View file

@ -11,12 +11,12 @@ import (
type responseService struct {
respSvc *response.Service
svc accounting.Service
svc Server
}
// NewResponseService returns accounting service instance that passes internal service
// call to response service.
func NewResponseService(accSvc accounting.Service, respSvc *response.Service) accounting.Service {
func NewResponseService(accSvc Server, respSvc *response.Service) Server {
return &responseService{
respSvc: respSvc,
svc: accSvc,

View file

@ -0,0 +1,12 @@
package accounting
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
)
// Server is an interface of the NeoFS API Accounting service server
type Server interface {
Balance(context.Context, *accounting.BalanceRequest) (*accounting.BalanceResponse, error)
}

View file

@ -11,10 +11,10 @@ import (
type signService struct {
sigSvc *util.SignService
svc accounting.Service
svc Server
}
func NewSignService(key *ecdsa.PrivateKey, svc accounting.Service) accounting.Service {
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
return &signService{
sigSvc: util.NewUnarySignService(key),
svc: svc,

View file

@ -17,13 +17,13 @@ type ServiceExecutor interface {
}
type executorSvc struct {
container.Service
Server
exec ServiceExecutor
}
// NewExecutionService wraps ServiceExecutor and returns Container Service interface.
func NewExecutionService(exec ServiceExecutor) container.Service {
func NewExecutionService(exec ServiceExecutor) Server {
return &executorSvc{
exec: exec,
}

View file

@ -11,12 +11,12 @@ import (
type responseService struct {
respSvc *response.Service
svc container.Service
svc Server
}
// NewResponseService returns container service instance that passes internal service
// call to response service.
func NewResponseService(cnrSvc container.Service, respSvc *response.Service) container.Service {
func NewResponseService(cnrSvc Server, respSvc *response.Service) Server {
return &responseService{
respSvc: respSvc,
svc: cnrSvc,

View file

@ -0,0 +1,18 @@
package container
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/container"
)
// Server is an interface of the NeoFS API Container service server
type Server interface {
Put(context.Context, *container.PutRequest) (*container.PutResponse, error)
Get(context.Context, *container.GetRequest) (*container.GetResponse, error)
Delete(context.Context, *container.DeleteRequest) (*container.DeleteResponse, error)
List(context.Context, *container.ListRequest) (*container.ListResponse, error)
SetExtendedACL(context.Context, *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error)
GetExtendedACL(context.Context, *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error)
AnnounceUsedSpace(context.Context, *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error)
}

View file

@ -11,10 +11,10 @@ import (
type signService struct {
sigSvc *util.SignService
svc container.Service
svc Server
}
func NewSignService(key *ecdsa.PrivateKey, svc container.Service) container.Service {
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
return &signService{
sigSvc: util.NewUnarySignService(key),
svc: svc,

View file

@ -30,7 +30,7 @@ type NetworkInfo interface {
Dump() (*netmap.NetworkInfo, error)
}
func NewExecutionService(s NodeState, v *pkg.Version, netInfo NetworkInfo) netmap.Service {
func NewExecutionService(s NodeState, v *pkg.Version, netInfo NetworkInfo) Server {
if s == nil || v == nil || netInfo == nil {
// this should never happen, otherwise it programmers bug
panic("can't create netmap execution service")

View file

@ -11,12 +11,12 @@ import (
type responseService struct {
respSvc *response.Service
svc netmap.Service
svc Server
}
// NewResponseService returns netmap service instance that passes internal service
// call to response service.
func NewResponseService(nmSvc netmap.Service, respSvc *response.Service) netmap.Service {
func NewResponseService(nmSvc Server, respSvc *response.Service) Server {
return &responseService{
respSvc: respSvc,
svc: nmSvc,

View file

@ -0,0 +1,13 @@
package netmap
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
)
// Server is an interface of the NeoFS API Netmap service server
type Server interface {
LocalNodeInfo(context.Context, *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error)
NetworkInfo(context.Context, *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error)
}

View file

@ -11,10 +11,10 @@ import (
type signService struct {
sigSvc *util.SignService
svc netmap.Service
svc Server
}
func NewSignService(key *ecdsa.PrivateKey, svc netmap.Service) netmap.Service {
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
return &signService{
sigSvc: util.NewUnarySignService(key),
svc: svc,

View file

@ -34,7 +34,7 @@ type (
putStreamBasicChecker struct {
source *Service
next object.PutObjectStreamer
next objectSvc.PutObjectStream
*eACLCfg
}
@ -174,7 +174,7 @@ func (b Service) Get(request *object.GetRequest, stream objectSvc.GetObjectStrea
})
}
func (b Service) Put(ctx context.Context) (object.PutObjectStreamer, error) {
func (b Service) Put(ctx context.Context) (objectSvc.PutObjectStream, error) {
streamer, err := b.next.Put(ctx)
return putStreamBasicChecker{

View file

@ -21,7 +21,7 @@ type (
}
putStreamMetric struct {
stream object.PutObjectStreamer
stream PutObjectStream
metrics MetricRegister
start time.Time
}
@ -69,7 +69,7 @@ func (m MetricCollector) Get(req *object.GetRequest, stream GetObjectStream) err
})
}
func (m MetricCollector) Put(ctx context.Context) (object.PutObjectStreamer, error) {
func (m MetricCollector) Put(ctx context.Context) (PutObjectStream, error) {
t := time.Now()
defer func() {
m.metrics.IncPutReqCounter()

View file

@ -3,7 +3,7 @@ package putsvc
import (
"context"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
"github.com/pkg/errors"
)
@ -34,7 +34,7 @@ func NewService(opts ...Option) *Service {
}
// Put calls internal service and returns v2 object streamer.
func (s *Service) Put(ctx context.Context) (objectV2.PutObjectStreamer, error) {
func (s *Service) Put(ctx context.Context) (object.PutObjectStream, error) {
stream, err := s.svc.Put(ctx)
if err != nil {
return nil, errors.Wrapf(err, "(%T) could not open object put stream", s)

View file

@ -72,7 +72,7 @@ func (s *putStreamResponser) CloseAndRecv() (*object.PutResponse, error) {
return r.(*object.PutResponse), nil
}
func (s *ResponseService) Put(ctx context.Context) (object.PutObjectStreamer, error) {
func (s *ResponseService) Put(ctx context.Context) (PutObjectStream, error) {
stream, err := s.svc.Put(ctx)
if err != nil {
return nil, errors.Wrap(err, "could not create Put object streamer")

View file

@ -25,11 +25,17 @@ type SearchStream interface {
Send(*object.SearchResponse) error
}
// PutObjectStream is an interface of NeoFS API v2 compatible client's object streamer.
type PutObjectStream interface {
Send(*object.PutRequest) error
CloseAndRecv() (*object.PutResponse, error)
}
// ServiceServer is an interface of utility
// serving v2 Object service.
type ServiceServer interface {
Get(*object.GetRequest, GetObjectStream) error
Put(context.Context) (object.PutObjectStreamer, error)
Put(context.Context) (PutObjectStream, error)
Head(context.Context, *object.HeadRequest) (*object.HeadResponse, error)
Search(*object.SearchRequest, SearchStream) error
Delete(context.Context, *object.DeleteRequest) (*object.DeleteResponse, error)

View file

@ -80,7 +80,7 @@ func (s *putStreamSigner) CloseAndRecv() (*object.PutResponse, error) {
return r.(*object.PutResponse), nil
}
func (s *SignService) Put(ctx context.Context) (object.PutObjectStreamer, error) {
func (s *SignService) Put(ctx context.Context) (PutObjectStream, error) {
stream, err := s.svc.Put(ctx)
if err != nil {
return nil, errors.Wrap(err, "could not create Put object streamer")

View file

@ -87,7 +87,7 @@ func (c *TransportSplitter) Get(req *object.GetRequest, stream GetObjectStream)
})
}
func (c TransportSplitter) Put(ctx context.Context) (object.PutObjectStreamer, error) {
func (c TransportSplitter) Put(ctx context.Context) (PutObjectStream, error) {
return c.next.Put(ctx)
}

View file

@ -16,7 +16,7 @@ type executorSvc struct {
}
// NewExecutionService wraps ServiceExecutor and returns Session Service interface.
func NewExecutionService(exec ServiceExecutor) session.Service {
func NewExecutionService(exec ServiceExecutor) Server {
return &executorSvc{
exec: exec,
}

View file

@ -11,12 +11,12 @@ import (
type responseService struct {
respSvc *response.Service
svc session.Service
svc Server
}
// NewResponseService returns session service instance that passes internal service
// call to response service.
func NewResponseService(ssSvc session.Service, respSvc *response.Service) session.Service {
func NewResponseService(ssSvc Server, respSvc *response.Service) Server {
return &responseService{
respSvc: respSvc,
svc: ssSvc,

View file

@ -0,0 +1,12 @@
package session
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/session"
)
// Server is an interface of the NeoFS API Session service server
type Server interface {
Create(context.Context, *session.CreateRequest) (*session.CreateResponse, error)
}

View file

@ -11,10 +11,10 @@ import (
type signService struct {
sigSvc *util.SignService
svc session.Service
svc Server
}
func NewSignService(key *ecdsa.PrivateKey, svc session.Service) session.Service {
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
return &signService{
sigSvc: util.NewUnarySignService(key),
svc: svc,