[#1131] *: Adopt SDK changes

`object.Address` has been moved to `object/address`
`object.ID` has been moved to `object/id`

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-01-26 15:11:13 +03:00 committed by Alex Vanin
parent 1c821d6c36
commit 1667ec9e6d
139 changed files with 652 additions and 562 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap"
)
@ -132,7 +133,7 @@ func (exec execCtx) remoteClient(info client.NodeInfo) (searchClient, bool) {
return nil, false
}
func (exec *execCtx) writeIDList(ids []*objectSDK.ID) {
func (exec *execCtx) writeIDList(ids []*oidSDK.ID) {
err := exec.prm.writer.WriteIDs(ids)
switch {

View file

@ -5,6 +5,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
// Prm groups parameters of Get service call.
@ -23,12 +24,12 @@ type Prm struct {
// IDListWriter is an interface of target component
// to write list of object identifiers.
type IDListWriter interface {
WriteIDs([]*objectSDK.ID) error
WriteIDs([]*oidSDK.ID) error
}
// RequestForwarder is a callback for forwarding of the
// original Search requests.
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]*objectSDK.ID, error)
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]*oidSDK.ID, error)
// SetCommonParameters sets common parameters of the operation.
func (p *Prm) SetCommonParameters(common *util.CommonPrm) {

View file

@ -18,12 +18,13 @@ import (
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/stretchr/testify/require"
)
type idsErr struct {
ids []*objectSDK.ID
ids []*oidSDK.ID
err error
}
@ -45,7 +46,7 @@ type testClientCache struct {
}
type simpleIDWriter struct {
ids []*objectSDK.ID
ids []*oidSDK.ID
}
type testEpochReceiver uint64
@ -54,7 +55,7 @@ func (e testEpochReceiver) currentEpoch() (uint64, error) {
return uint64(e), nil
}
func (s *simpleIDWriter) WriteIDs(ids []*objectSDK.ID) error {
func (s *simpleIDWriter) WriteIDs(ids []*oidSDK.ID) error {
s.ids = append(s.ids, ids...)
return nil
}
@ -73,7 +74,7 @@ func (g *testTraverserGenerator) generateTraverser(_ *cid.ID, epoch uint64) (*pl
)
}
func (p *testPlacementBuilder) BuildPlacement(addr *objectSDK.Address, _ *netmap.PlacementPolicy) ([]netmap.Nodes, error) {
func (p *testPlacementBuilder) BuildPlacement(addr *addressSDK.Address, _ *netmap.PlacementPolicy) ([]netmap.Nodes, error) {
vs, ok := p.vectors[addr.String()]
if !ok {
return nil, errors.New("vectors for address not found")
@ -94,7 +95,7 @@ func (c *testClientCache) get(info clientcore.NodeInfo) (searchClient, error) {
return v, nil
}
func (s *testStorage) search(exec *execCtx) ([]*objectSDK.ID, error) {
func (s *testStorage) search(exec *execCtx) ([]*oidSDK.ID, error) {
v, ok := s.items[exec.containerID().String()]
if !ok {
return nil, nil
@ -103,7 +104,7 @@ func (s *testStorage) search(exec *execCtx) ([]*objectSDK.ID, error) {
return v.ids, v.err
}
func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*objectSDK.ID, error) {
func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*oidSDK.ID, error) {
v, ok := c.items[exec.containerID().String()]
if !ok {
return nil, nil
@ -112,7 +113,7 @@ func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*ob
return v.ids, v.err
}
func (c *testStorage) addResult(addr *cid.ID, ids []*objectSDK.ID, err error) {
func (c *testStorage) addResult(addr *cid.ID, ids []*oidSDK.ID, err error) {
c.items[addr.String()] = idsErr{
ids: ids,
err: err,
@ -124,11 +125,11 @@ func testSHA256() (cs [sha256.Size]byte) {
return cs
}
func generateIDs(num int) []*objectSDK.ID {
res := make([]*objectSDK.ID, num)
func generateIDs(num int) []*oidSDK.ID {
res := make([]*oidSDK.ID, num)
for i := 0; i < num; i++ {
res[i] = objectSDK.NewID()
res[i] = oidSDK.NewID()
res[i].SetSHA256(testSHA256())
}
@ -269,7 +270,7 @@ func TestGetRemoteSmall(t *testing.T) {
}
t.Run("OK", func(t *testing.T) {
addr := objectSDK.NewAddress()
addr := addressSDK.NewAddress()
addr.SetContainerID(id)
ns, as := testNodeMatrix(t, placementDim)
@ -329,7 +330,7 @@ func TestGetFromPastEpoch(t *testing.T) {
cnr := container.New(container.WithPolicy(pp))
cid := container.CalculateID(cnr)
addr := objectSDK.NewAddress()
addr := addressSDK.NewAddress()
addr.SetContainerID(cid)
ns, as := testNodeMatrix(t, placementDim)
@ -392,7 +393,7 @@ func TestGetFromPastEpoch(t *testing.T) {
commonPrm := new(util.CommonPrm)
p.SetCommonParameters(commonPrm)
assertContains := func(idsList ...[]*objectSDK.ID) {
assertContains := func(idsList ...[]*oidSDK.ID) {
var sz int
for _, ids := range idsList {

View file

@ -10,7 +10,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/session"
"go.uber.org/zap"
)
@ -25,7 +25,7 @@ type Service struct {
type Option func(*cfg)
type searchClient interface {
searchObjects(*execCtx, client.NodeInfo) ([]*object.ID, error)
searchObjects(*execCtx, client.NodeInfo) ([]*oidSDK.ID, error)
}
type ClientConstructor interface {
@ -36,7 +36,7 @@ type cfg struct {
log *logger.Logger
localStorage interface {
search(*execCtx) ([]*object.ID, error)
search(*execCtx) ([]*oidSDK.ID, error)
}
clientConstructor interface {

View file

@ -10,7 +10,8 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
type uniqueIDWriter struct {
@ -44,7 +45,7 @@ func newUniqueAddressWriter(w IDListWriter) IDListWriter {
}
}
func (w *uniqueIDWriter) WriteIDs(list []*objectSDK.ID) error {
func (w *uniqueIDWriter) WriteIDs(list []*oidSDK.ID) error {
w.mtx.Lock()
for i := 0; i < len(list); i++ { // don't use range, slice mutates in body
@ -79,7 +80,7 @@ func (c *clientConstructorWrapper) get(info client.NodeInfo) (searchClient, erro
}, nil
}
func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*objectSDK.ID, error) {
func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*oidSDK.ID, error) {
if exec.prm.forwarder != nil {
return exec.prm.forwarder(info, c.client)
}
@ -110,7 +111,7 @@ func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*o
return res.IDList(), nil
}
func (e *storageEngineWrapper) search(exec *execCtx) ([]*objectSDK.ID, error) {
func (e *storageEngineWrapper) search(exec *execCtx) ([]*oidSDK.ID, error) {
r, err := (*engine.StorageEngine)(e).Select(new(engine.SelectPrm).
WithFilters(exec.searchFilters()).
WithContainerID(exec.containerID()),
@ -122,8 +123,8 @@ func (e *storageEngineWrapper) search(exec *execCtx) ([]*objectSDK.ID, error) {
return idsFromAddresses(r.AddressList()), nil
}
func idsFromAddresses(addrs []*objectSDK.Address) []*objectSDK.ID {
ids := make([]*objectSDK.ID, len(addrs))
func idsFromAddresses(addrs []*addressSDK.Address) []*oidSDK.ID {
ids := make([]*oidSDK.ID, len(addrs))
for i := range addrs {
ids[i] = addrs[i].ObjectID()
@ -133,7 +134,7 @@ func idsFromAddresses(addrs []*objectSDK.Address) []*objectSDK.ID {
}
func (e *traverseGeneratorWrapper) generateTraverser(cid *cid.ID, epoch uint64) (*placement.Traverser, error) {
a := objectSDK.NewAddress()
a := addressSDK.NewAddress()
a.SetContainerID(cid)
return (*util.TraverserGenerator)(e).GenerateTraverser(a, epoch)

View file

@ -4,14 +4,14 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
type streamWriter struct {
stream objectSvc.SearchStream
}
func (s *streamWriter) WriteIDs(ids []*objectSDK.ID) error {
func (s *streamWriter) WriteIDs(ids []*oidSDK.ID) error {
r := new(object.SearchResponse)
body := new(object.SearchResponseBody)

View file

@ -19,6 +19,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStream) (*searchsvc.Prm, error) {
@ -44,7 +45,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
return nil, err
}
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]*objectSDK.ID, error) {
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]*oidSDK.ID, error) {
var err error
// once compose and resign forwarding request
@ -72,7 +73,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
// code below is copy-pasted from c.SearchObjects implementation,
// perhaps it is worth highlighting the utility function in neofs-api-go
var (
searchResult []*objectSDK.ID
searchResult []*oidSDK.ID
resp = new(objectV2.SearchResponse)
)
@ -99,7 +100,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
chunk := resp.GetBody().GetIDList()
for i := range chunk {
searchResult = append(searchResult, objectSDK.NewIDFromV2(chunk[i]))
searchResult = append(searchResult, oidSDK.NewIDFromV2(chunk[i]))
}
}
@ -114,11 +115,11 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
return p, nil
}
func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]*objectSDK.ID, error)) searchsvc.RequestForwarder {
return func(info client.NodeInfo, c client.MultiAddressClient) ([]*objectSDK.ID, error) {
func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]*oidSDK.ID, error)) searchsvc.RequestForwarder {
return func(info client.NodeInfo, c client.MultiAddressClient) ([]*oidSDK.ID, error) {
var (
firstErr error
res []*objectSDK.ID
res []*oidSDK.ID
key = info.PublicKey()
)