Skip to content

Object inlines #3097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 30, 2025
91 changes: 42 additions & 49 deletions cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import (
"bytes"
"context"
"crypto/ecdsa"
"errors"
"fmt"
"sync/atomic"

"github.com/google/uuid"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/nspcc-dev/neofs-api-go/v2/object"
objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
replicatorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/replicator"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
Expand All @@ -21,14 +22,10 @@
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl"
v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2"
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
deletesvcV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/delete/v2"
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
getsvcV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/get/v2"
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
putsvcV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/put/v2"
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
searchsvcV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/search/v2"
"github.com/nspcc-dev/neofs-node/pkg/services/object/split"
"github.com/nspcc-dev/neofs-node/pkg/services/object/tombstone"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
Expand All @@ -48,13 +45,13 @@
)

type objectSvc struct {
put *putsvcV2.Service
put *putsvc.Service

search *searchsvcV2.Service
search *searchsvc.Service

get *getsvcV2.Service
get *getsvc.Service

delete *deletesvcV2.Service
delete *deletesvc.Service
}

func (c *cfg) MaxObjectSize() uint64 {
Expand All @@ -68,32 +65,32 @@
return sz
}

func (s *objectSvc) Put(ctx context.Context) (objectService.PutObjectStream, error) {
func (s *objectSvc) Put(ctx context.Context) (*putsvc.Streamer, error) {

Check warning on line 68 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L68

Added line #L68 was not covered by tests
return s.put.Put(ctx)
}

func (s *objectSvc) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) {
return s.get.Head(ctx, req)
func (s *objectSvc) Head(ctx context.Context, prm getsvc.HeadPrm) error {
return s.get.Head(ctx, prm)

Check warning on line 73 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L72-L73

Added lines #L72 - L73 were not covered by tests
}

func (s *objectSvc) Search(req *object.SearchRequest, stream objectService.SearchStream) error {
return s.search.Search(req, stream)
func (s *objectSvc) Search(ctx context.Context, prm searchsvc.Prm) error {
return s.search.Search(ctx, prm)

Check warning on line 77 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L76-L77

Added lines #L76 - L77 were not covered by tests
}

func (s *objectSvc) Get(req *object.GetRequest, stream objectService.GetObjectStream) error {
return s.get.Get(req, stream)
func (s *objectSvc) Get(ctx context.Context, prm getsvc.Prm) error {
return s.get.Get(ctx, prm)

Check warning on line 81 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L80-L81

Added lines #L80 - L81 were not covered by tests
}

func (s *objectSvc) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) {
return s.delete.Delete(ctx, req)
func (s *objectSvc) Delete(ctx context.Context, prm deletesvc.Prm) error {
return s.delete.Delete(ctx, prm)

Check warning on line 85 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L84-L85

Added lines #L84 - L85 were not covered by tests
}

func (s *objectSvc) GetRange(req *object.GetRangeRequest, stream objectService.GetObjectRangeStream) error {
return s.get.GetRange(req, stream)
func (s *objectSvc) GetRange(ctx context.Context, prm getsvc.RangePrm) error {
return s.get.GetRange(ctx, prm)

Check warning on line 89 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L88-L89

Added lines #L88 - L89 were not covered by tests
}

func (s *objectSvc) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
return s.get.GetRangeHash(ctx, req)
func (s *objectSvc) GetRangeHash(ctx context.Context, prm getsvc.RangeHashPrm) (*getsvc.RangeHashRes, error) {
return s.get.GetRangeHash(ctx, prm)

Check warning on line 93 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L92-L93

Added lines #L92 - L93 were not covered by tests
}

type delNetInfo struct {
Expand Down Expand Up @@ -232,11 +229,6 @@

*c.cfgObject.getSvc = *sGet // need smth better

sGetV2 := getsvcV2.NewService(
getsvcV2.WithInternalService(sGet),
getsvcV2.WithKeyStorage(keyStorage),
)

cnrNodes, err := newContainerNodes(c.cfgObject.cnrSource, c.netMapSource)
fatalOnErr(err)
c.cfgObject.containerNodes = cnrNodes
Expand All @@ -248,11 +240,6 @@
searchsvc.WithKeyStorage(keyStorage),
)

sSearchV2 := searchsvcV2.NewService(
searchsvcV2.WithInternalService(sSearch),
searchsvcV2.WithKeyStorage(keyStorage),
)

mNumber, err := c.shared.basics.cli.MagicNumber()
fatalOnErr(err)

Expand All @@ -272,11 +259,6 @@
putsvc.WithTombstoneVerifier(tombstone.NewVerifier(objectSource{sGet, sSearch})),
)

sPutV2 := putsvcV2.NewService(
putsvcV2.WithInternalService(sPut),
putsvcV2.WithKey(&c.key.PrivateKey),
)

sDelete := deletesvc.New(
deletesvc.WithLogger(c.log),
deletesvc.WithPutService(sPut),
Expand All @@ -289,15 +271,11 @@
deletesvc.WithKeyStorage(keyStorage),
)

sDeleteV2 := deletesvcV2.NewService(
deletesvcV2.WithInternalService(sDelete),
)

objSvc := &objectSvc{
put: sPutV2,
search: sSearchV2,
get: sGetV2,
delete: sDeleteV2,
put: sPut,
search: sSearch,
get: sGet,
delete: sDelete,

Check warning on line 278 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L275-L278

Added lines #L275 - L278 were not covered by tests
}

// cachedFirstObjectsNumber is a total cached objects number; the V2 split scheme
Expand All @@ -324,7 +302,11 @@
SetHeaderSource(cachedHeaderSource(sGet, cachedFirstObjectsNumber, c.log)),
)

server := objectService.New(objSvc, mNumber, fsChain, (*putObjectServiceWrapper)(sPut), c.shared.basics.key.PrivateKey, c.metricsCollector, aclChecker, aclSvc)
storage := storageForObjectService{
putSvc: sPut,
keys: keyStorage,
}
server := objectService.New(objSvc, mNumber, fsChain, storage, c.shared.basics.key.PrivateKey, c.metricsCollector, aclChecker, aclSvc)

Check warning on line 309 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L305-L309

Added lines #L305 - L309 were not covered by tests

for _, srv := range c.cfgGRPC.servers {
objectGRPC.RegisterObjectServiceServer(srv, server)
Expand Down Expand Up @@ -633,10 +615,21 @@
// maintenance now.
func (x *fsChainForObjects) LocalNodeUnderMaintenance() bool { return x.isMaintenance.Load() }

type putObjectServiceWrapper putsvc.Service
type storageForObjectService struct {
putSvc *putsvc.Service
keys *util.KeyStorage
}

func (x *putObjectServiceWrapper) VerifyAndStoreObject(obj objectSDK.Object) error {
return (*putsvc.Service)(x).ValidateAndStoreObjectLocally(obj)
func (x storageForObjectService) VerifyAndStoreObjectLocally(obj objectSDK.Object) error {
return x.putSvc.ValidateAndStoreObjectLocally(obj)

Check warning on line 624 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L623-L624

Added lines #L623 - L624 were not covered by tests
}

func (x storageForObjectService) GetSessionPrivateKey(usr user.ID, uid uuid.UUID) (ecdsa.PrivateKey, error) {
k, err := x.keys.GetKey(&util.SessionInfo{ID: uid, Owner: usr})
if err != nil {
return ecdsa.PrivateKey{}, err
}
return *k, nil

Check warning on line 632 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L627-L632

Added lines #L627 - L632 were not covered by tests
}

type objectSource struct {
Expand Down
59 changes: 0 additions & 59 deletions pkg/services/object/delete/v2/service.go

This file was deleted.

54 changes: 0 additions & 54 deletions pkg/services/object/delete/v2/util.go

This file was deleted.

Loading
Loading