2020-08-24 14:07:08 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/container"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/util"
|
2020-08-24 14:07:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type signService struct {
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc *util.SignService
|
2020-08-26 09:20:26 +00:00
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
svc Server
|
2020-08-24 14:07:08 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
|
2020-08-24 14:07:08 +00:00
|
|
|
return &signService{
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc: util.NewUnarySignService(key),
|
|
|
|
svc: svc,
|
2020-08-24 14:07:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-08-26 09:20:26 +00:00
|
|
|
return s.svc.Put(ctx, req.(*container.PutRequest))
|
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.PutResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:07:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.PutResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-09-02 16:25:46 +00:00
|
|
|
return s.svc.Delete(ctx, req.(*container.DeleteRequest))
|
2020-08-26 09:20:26 +00:00
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.DeleteResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:07:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.DeleteResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-09-02 16:25:46 +00:00
|
|
|
return s.svc.Get(ctx, req.(*container.GetRequest))
|
2020-08-26 09:20:26 +00:00
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.GetResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:07:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.GetResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-08-26 09:20:26 +00:00
|
|
|
return s.svc.List(ctx, req.(*container.ListRequest))
|
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.ListResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:07:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.ListResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-08-26 09:20:26 +00:00
|
|
|
return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest))
|
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.SetExtendedACLResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:07:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.SetExtendedACLResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-08-26 09:20:26 +00:00
|
|
|
return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest))
|
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.GetExtendedACLResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:07:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.GetExtendedACLResponse), nil
|
|
|
|
}
|
2021-02-01 12:43:09 +00:00
|
|
|
|
|
|
|
func (s *signService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) {
|
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2021-02-01 12:43:09 +00:00
|
|
|
return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest))
|
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(container.AnnounceUsedSpaceResponse)
|
|
|
|
},
|
2021-02-01 12:43:09 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*container.AnnounceUsedSpaceResponse), nil
|
|
|
|
}
|