[#1087] *: Adopt SDK changes

- Update `neofs-sdk-go`:
v0.0.0-20211230072947-1fe37df88f80 => v0.0.0-20220113123743-7f3162110659

- Add client interface that duplicates SDK's client behaviour and new
`MultiAddressClient` interface that has method that iterates over wrapped
clients.

- Also start using simple client mode that does not require parsing statuses
outside the SDK library.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-01-13 18:01:50 +03:00 committed by Pavel Karpy
parent 58d90eec7d
commit 7c02a2e251
32 changed files with 149 additions and 178 deletions

View file

@ -7,7 +7,6 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/accounting" "github.com/nspcc-dev/neofs-sdk-go/accounting"
"github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/client"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
"github.com/nspcc-dev/neofs-sdk-go/container" "github.com/nspcc-dev/neofs-sdk-go/container"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/eacl" "github.com/nspcc-dev/neofs-sdk-go/eacl"
@ -39,10 +38,6 @@ func BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
res.cliRes, err = prm.cli.GetBalance(context.Background(), prm.ownerID, res.cliRes, err = prm.cli.GetBalance(context.Background(), prm.ownerID,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -70,10 +65,6 @@ func ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
res.cliRes, err = prm.cli.ListContainers(context.Background(), prm.ownerID, res.cliRes, err = prm.cli.ListContainers(context.Background(), prm.ownerID,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -114,10 +105,6 @@ func PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -145,10 +132,6 @@ func GetContainer(prm GetContainerPrm) (res GetContainerRes, err error) {
res.cliRes, err = prm.cli.GetContainer(context.Background(), prm.cnrID, res.cliRes, err = prm.cli.GetContainer(context.Background(), prm.cnrID,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -172,16 +155,10 @@ type DeleteContainerRes struct{}
// //
// Returns any error prevented the operation from completing correctly in error return. // Returns any error prevented the operation from completing correctly in error return.
func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error) { func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error) {
var cliRes *client.ContainerDeleteRes _, err = prm.cli.DeleteContainer(context.Background(), prm.cnrID,
cliRes, err = prm.cli.DeleteContainer(context.Background(), prm.cnrID,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(cliRes.Status())
}
return return
} }
@ -209,10 +186,6 @@ func EACL(prm EACLPrm) (res EACLRes, err error) {
res.cliRes, err = prm.cli.EACL(context.Background(), prm.cnrID, res.cliRes, err = prm.cli.EACL(context.Background(), prm.cnrID,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -242,16 +215,10 @@ type SetEACLRes struct{}
// //
// Returns any error prevented the operation from completing correctly in error return. // Returns any error prevented the operation from completing correctly in error return.
func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) { func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
var cliRes *client.SetEACLRes _, err = prm.cli.SetEACL(context.Background(), prm.eaclTable,
cliRes, err = prm.cli.SetEACL(context.Background(), prm.eaclTable,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(cliRes.Status())
}
return return
} }
@ -278,10 +245,6 @@ func NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
res.cliRes, err = prm.cli.NetworkInfo(context.Background(), res.cliRes, err = prm.cli.NetworkInfo(context.Background(),
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -313,10 +276,6 @@ func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
res.cliRes, err = prm.cli.EndpointInfo(context.Background(), res.cliRes, err = prm.cli.EndpointInfo(context.Background(),
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -348,10 +307,6 @@ func CreateSession(prm CreateSessionPrm) (res CreateSessionRes, err error) {
res.cliRes, err = prm.cli.CreateSession(context.Background(), math.MaxUint64, res.cliRes, err = prm.cli.CreateSession(context.Background(), math.MaxUint64,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
) )
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -399,10 +354,6 @@ func PutObject(prm PutObjectPrm) (res PutObjectRes, err error) {
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -436,10 +387,6 @@ func DeleteObject(prm DeleteObjectPrm) (res DeleteObjectRes, err error) {
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -457,7 +404,7 @@ type GetObjectRes struct {
cliRes *client.ObjectGetRes cliRes *client.ObjectGetRes
} }
// Object returns header of the request object. // Header returns header of the request object.
func (x GetObjectRes) Header() *object.Object { func (x GetObjectRes) Header() *object.Object {
return x.cliRes.Object() return x.cliRes.Object()
} }
@ -480,10 +427,6 @@ func GetObject(prm GetObjectPrm) (res GetObjectRes, err error) {
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -533,10 +476,6 @@ func HeadObject(prm HeadObjectPrm) (res HeadObjectRes, err error) {
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -578,10 +517,6 @@ func SearchObjects(prm SearchObjectsPrm) (res SearchObjectsRes, err error) {
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -643,10 +578,6 @@ func HashPayloadRanges(prm HashPayloadRangesPrm) (res HashPayloadRangesRes, err
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(res.cliRes.Status())
}
return return
} }
@ -683,17 +614,11 @@ func PayloadRange(prm PayloadRangePrm) (res PayloadRangeRes, err error) {
cliPrm.WithDataWriter(prm.wrt) cliPrm.WithDataWriter(prm.wrt)
cliPrm.WithRange(prm.rng) cliPrm.WithRange(prm.rng)
var cliRes *client.ObjectRangeRes _, err = prm.cli.ObjectPayloadRangeData(context.Background(), &cliPrm, append(prm.opts,
cliRes, err = prm.cli.ObjectPayloadRangeData(context.Background(), &cliPrm, append(prm.opts,
client.WithKey(prm.privKey), client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken), client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken), client.WithBearer(prm.bearerToken),
)...) )...)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(cliRes.Status())
}
return return
} }

View file

@ -15,13 +15,13 @@ import (
// here are small structures with public setters to share between parameter structures // here are small structures with public setters to share between parameter structures
type commonPrm struct { type commonPrm struct {
cli client.Client cli *client.Client
privKey *ecdsa.PrivateKey privKey *ecdsa.PrivateKey
} }
// SetClient sets base client for NeoFS API communication. // SetClient sets base client for NeoFS API communication.
func (x *commonPrm) SetClient(cli client.Client) { func (x *commonPrm) SetClient(cli *client.Client) {
x.cli = cli x.cli = cli
} }

View file

@ -46,7 +46,7 @@ const (
basicACLNoFinalAppend = "eacl-public-append" basicACLNoFinalAppend = "eacl-public-append"
) )
var wellKnownBasicACL = map[string]uint32{ var wellKnownBasicACL = map[string]acl.BasicACL{
basicACLPublic: acl.PublicBasicRule, basicACLPublic: acl.PublicBasicRule,
basicACLPrivate: acl.PrivateBasicRule, basicACLPrivate: acl.PrivateBasicRule,
basicACLReadOnly: acl.ReadOnlyBasicRule, basicACLReadOnly: acl.ReadOnlyBasicRule,
@ -668,7 +668,7 @@ func parseAttributes(attributes []string) ([]*container.Attribute, error) {
return result, nil return result, nil
} }
func parseBasicACL(basicACL string) (uint32, error) { func parseBasicACL(basicACL string) (acl.BasicACL, error) {
if value, ok := wellKnownBasicACL[basicACL]; ok { if value, ok := wellKnownBasicACL[basicACL]; ok {
return value, nil return value, nil
} }
@ -680,7 +680,7 @@ func parseBasicACL(basicACL string) (uint32, error) {
return 0, fmt.Errorf("can't parse basic ACL: %s", basicACL) return 0, fmt.Errorf("can't parse basic ACL: %s", basicACL)
} }
return uint32(value), nil return acl.BasicACL(value), nil
} }
func parseNonce(nonce string) (uuid.UUID, error) { func parseNonce(nonce string) (uuid.UUID, error) {
@ -744,7 +744,7 @@ func prettyPrintContainer(cmd *cobra.Command, cnr *container.Container, jsonEnco
cmd.Println("owner ID:", cnr.OwnerID()) cmd.Println("owner ID:", cnr.OwnerID())
basicACL := cnr.BasicACL() basicACL := cnr.BasicACL()
prettyPrintBasicACL(cmd, basicACL) prettyPrintBasicACL(cmd, acl.BasicACL(basicACL))
for _, attribute := range cnr.Attributes() { for _, attribute := range cnr.Attributes() {
if attribute.Key() == container.AttributeTimestamp { if attribute.Key() == container.AttributeTimestamp {
@ -825,7 +825,7 @@ func printJSONMarshaler(cmd *cobra.Command, j json.Marshaler, entity string) {
cmd.Println(buf) cmd.Println(buf)
} }
func prettyPrintBasicACL(cmd *cobra.Command, basicACL uint32) { func prettyPrintBasicACL(cmd *cobra.Command, basicACL acl.BasicACL) {
cmd.Printf("basic ACL: %.8x", basicACL) cmd.Printf("basic ACL: %.8x", basicACL)
for k, v := range wellKnownBasicACL { for k, v := range wellKnownBasicACL {
if v == basicACL { if v == basicACL {

View file

@ -238,7 +238,7 @@ func healthCheck(cmd *cobra.Command, _ []string) {
cmd.Printf("Health status: %s\n", resp.GetBody().GetHealthStatus()) cmd.Printf("Health status: %s\n", resp.GetBody().GetHealthStatus())
} }
func healthCheckIR(cmd *cobra.Command, key *ecdsa.PrivateKey, c client.Client) { func healthCheckIR(cmd *cobra.Command, key *ecdsa.PrivateKey, c *client.Client) {
req := new(ircontrol.HealthCheckRequest) req := new(ircontrol.HealthCheckRequest)
req.SetBody(new(ircontrol.HealthCheckRequest_Body)) req.SetBody(new(ircontrol.HealthCheckRequest_Body))
@ -430,7 +430,7 @@ func listShards(cmd *cobra.Command, _ []string) {
// getControlSDKClient is the same getSDKClient but with // getControlSDKClient is the same getSDKClient but with
// another RPC endpoint flag. // another RPC endpoint flag.
func getControlSDKClient(key *ecdsa.PrivateKey) (client.Client, error) { func getControlSDKClient(key *ecdsa.PrivateKey) (*client.Client, error) {
netAddr, err := getEndpointAddress(controlRPC) netAddr, err := getEndpointAddress(controlRPC)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -289,7 +289,7 @@ func getEndpointAddress(endpointFlag string) (addr network.Address, err error) {
} }
type clientWithKey interface { type clientWithKey interface {
SetClient(client.Client) SetClient(*client.Client)
SetKey(*ecdsa.PrivateKey) SetKey(*ecdsa.PrivateKey)
} }
@ -325,7 +325,7 @@ func prepareBearerPrm(cmd *cobra.Command, prm bearerPrm) {
// getSDKClient returns default neofs-api-go sdk client. Consider using // getSDKClient returns default neofs-api-go sdk client. Consider using
// opts... to provide TTL or other global configuration flags. // opts... to provide TTL or other global configuration flags.
func getSDKClient(key *ecdsa.PrivateKey) (client.Client, error) { func getSDKClient(key *ecdsa.PrivateKey) (*client.Client, error) {
netAddr, err := getEndpointAddress(rpc) netAddr, err := getEndpointAddress(rpc)
if err != nil { if err != nil {
return nil, err return nil, err
@ -334,6 +334,7 @@ func getSDKClient(key *ecdsa.PrivateKey) (client.Client, error) {
options := []client.Option{ options := []client.Option{
client.WithAddress(netAddr.HostAddr()), client.WithAddress(netAddr.HostAddr()),
client.WithDefaultPrivateKey(key), client.WithDefaultPrivateKey(key),
client.WithNeoFSErrorParsing(),
} }
if netAddr.TLSEnabled() { if netAddr.TLSEnabled() {

View file

@ -249,7 +249,7 @@ type remoteLoadAnnounceProvider struct {
netmapKeys netmapCore.AnnouncedKeys netmapKeys netmapCore.AnnouncedKeys
clientCache interface { clientCache interface {
Get(client.NodeInfo) (apiClient.Client, error) Get(client.NodeInfo) (client.Client, error)
} }
deadEndProvider loadcontroller.WriterProvider deadEndProvider loadcontroller.WriterProvider
@ -284,7 +284,7 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
} }
type remoteLoadAnnounceWriterProvider struct { type remoteLoadAnnounceWriterProvider struct {
client apiClient.Client client client.Client
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
} }
@ -299,7 +299,7 @@ func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (load
type remoteLoadAnnounceWriter struct { type remoteLoadAnnounceWriter struct {
ctx context.Context ctx context.Context
client apiClient.Client client client.Client
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
buf []containerSDK.UsedSpaceAnnouncement buf []containerSDK.UsedSpaceAnnouncement

View file

@ -172,13 +172,13 @@ func (f *innerRingFetcherWithoutNotary) InnerRingKeys() ([][]byte, error) {
type coreClientConstructor reputationClientConstructor type coreClientConstructor reputationClientConstructor
func (x *coreClientConstructor) Get(info coreclient.NodeInfo) (coreclient.Client, error) { func (x *coreClientConstructor) Get(info coreclient.NodeInfo) (coreclient.MultiAddressClient, error) {
c, err := (*reputationClientConstructor)(x).Get(info) c, err := (*reputationClientConstructor)(x).Get(info)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return c.(coreclient.Client), nil return c.(coreclient.MultiAddressClient), nil
} }
func initObjectService(c *cfg) { func initObjectService(c *cfg) {
@ -440,12 +440,12 @@ type reputationClientConstructor struct {
trustStorage *truststorage.Storage trustStorage *truststorage.Storage
basicConstructor interface { basicConstructor interface {
Get(coreclient.NodeInfo) (client.Client, error) Get(coreclient.NodeInfo) (coreclient.Client, error)
} }
} }
type reputationClient struct { type reputationClient struct {
coreclient.Client coreclient.MultiAddressClient
prm truststorage.UpdatePrm prm truststorage.UpdatePrm
@ -461,7 +461,7 @@ func (c *reputationClient) submitResult(err error) {
} }
func (c *reputationClient) PutObject(ctx context.Context, prm *client.PutObjectParams, opts ...client.CallOption) (*client.ObjectPutRes, error) { func (c *reputationClient) PutObject(ctx context.Context, prm *client.PutObjectParams, opts ...client.CallOption) (*client.ObjectPutRes, error) {
res, err := c.Client.PutObject(ctx, prm, opts...) res, err := c.MultiAddressClient.PutObject(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
@ -469,7 +469,7 @@ func (c *reputationClient) PutObject(ctx context.Context, prm *client.PutObjectP
} }
func (c *reputationClient) DeleteObject(ctx context.Context, prm *client.DeleteObjectParams, opts ...client.CallOption) (*client.ObjectDeleteRes, error) { func (c *reputationClient) DeleteObject(ctx context.Context, prm *client.DeleteObjectParams, opts ...client.CallOption) (*client.ObjectDeleteRes, error) {
res, err := c.Client.DeleteObject(ctx, prm, opts...) res, err := c.MultiAddressClient.DeleteObject(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
@ -477,7 +477,7 @@ func (c *reputationClient) DeleteObject(ctx context.Context, prm *client.DeleteO
} }
func (c *reputationClient) GetObject(ctx context.Context, prm *client.GetObjectParams, opts ...client.CallOption) (*client.ObjectGetRes, error) { func (c *reputationClient) GetObject(ctx context.Context, prm *client.GetObjectParams, opts ...client.CallOption) (*client.ObjectGetRes, error) {
res, err := c.Client.GetObject(ctx, prm, opts...) res, err := c.MultiAddressClient.GetObject(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
@ -485,7 +485,7 @@ func (c *reputationClient) GetObject(ctx context.Context, prm *client.GetObjectP
} }
func (c *reputationClient) HeadObject(ctx context.Context, prm *client.ObjectHeaderParams, opts ...client.CallOption) (*client.ObjectHeadRes, error) { func (c *reputationClient) HeadObject(ctx context.Context, prm *client.ObjectHeaderParams, opts ...client.CallOption) (*client.ObjectHeadRes, error) {
res, err := c.Client.HeadObject(ctx, prm, opts...) res, err := c.MultiAddressClient.HeadObject(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
@ -493,7 +493,7 @@ func (c *reputationClient) HeadObject(ctx context.Context, prm *client.ObjectHea
} }
func (c *reputationClient) ObjectPayloadRangeData(ctx context.Context, prm *client.RangeDataParams, opts ...client.CallOption) (*client.ObjectRangeRes, error) { func (c *reputationClient) ObjectPayloadRangeData(ctx context.Context, prm *client.RangeDataParams, opts ...client.CallOption) (*client.ObjectRangeRes, error) {
res, err := c.Client.ObjectPayloadRangeData(ctx, prm, opts...) res, err := c.MultiAddressClient.ObjectPayloadRangeData(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
@ -501,7 +501,7 @@ func (c *reputationClient) ObjectPayloadRangeData(ctx context.Context, prm *clie
} }
func (c *reputationClient) HashObjectPayloadRanges(ctx context.Context, prm *client.RangeChecksumParams, opts ...client.CallOption) (*client.ObjectRangeHashRes, error) { func (c *reputationClient) HashObjectPayloadRanges(ctx context.Context, prm *client.RangeChecksumParams, opts ...client.CallOption) (*client.ObjectRangeHashRes, error) {
res, err := c.Client.HashObjectPayloadRanges(ctx, prm, opts...) res, err := c.MultiAddressClient.HashObjectPayloadRanges(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
@ -509,14 +509,14 @@ func (c *reputationClient) HashObjectPayloadRanges(ctx context.Context, prm *cli
} }
func (c *reputationClient) SearchObjects(ctx context.Context, prm *client.SearchObjectParams, opts ...client.CallOption) (*client.ObjectSearchRes, error) { func (c *reputationClient) SearchObjects(ctx context.Context, prm *client.SearchObjectParams, opts ...client.CallOption) (*client.ObjectSearchRes, error) {
res, err := c.Client.SearchObjects(ctx, prm, opts...) res, err := c.MultiAddressClient.SearchObjects(ctx, prm, opts...)
c.submitResult(err) c.submitResult(err)
return res, err return res, err
} }
func (c *reputationClientConstructor) Get(info coreclient.NodeInfo) (client.Client, error) { func (c *reputationClientConstructor) Get(info coreclient.NodeInfo) (coreclient.Client, error) {
cl, err := c.basicConstructor.Get(info) cl, err := c.basicConstructor.Get(info)
if err != nil { if err != nil {
return nil, err return nil, err
@ -532,7 +532,7 @@ func (c *reputationClientConstructor) Get(info coreclient.NodeInfo) (client.Clie
prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey())) prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey()))
return &reputationClient{ return &reputationClient{
Client: cl.(coreclient.Client), MultiAddressClient: cl.(coreclient.MultiAddressClient),
prm: prm, prm: prm,
cons: c, cons: c,
}, nil }, nil

View file

@ -8,18 +8,17 @@ import (
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router" reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router"
trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller" trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller"
apiClient "github.com/nspcc-dev/neofs-sdk-go/client"
) )
type clientCache interface { type clientCache interface {
Get(client.NodeInfo) (apiClient.Client, error) Get(client.NodeInfo) (client.Client, error)
} }
// clientKeyRemoteProvider must provide remote writer and take into account // clientKeyRemoteProvider must provide remote writer and take into account
// that requests must be sent via passed api client and must be signed with // that requests must be sent via passed api client and must be signed with
// passed private key. // passed private key.
type clientKeyRemoteProvider interface { type clientKeyRemoteProvider interface {
WithClient(apiClient.Client) reputationcommon.WriterProvider WithClient(client.Client) reputationcommon.WriterProvider
} }
// remoteTrustProvider is implementation of reputation RemoteWriterProvider interface. // remoteTrustProvider is implementation of reputation RemoteWriterProvider interface.

View file

@ -5,10 +5,10 @@ import (
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/common" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/common"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/internal/client" internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/internal/client"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
eigentrustcalc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/eigentrust/calculator" eigentrustcalc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/eigentrust/calculator"
apiClient "github.com/nspcc-dev/neofs-sdk-go/client"
reputationapi "github.com/nspcc-dev/neofs-sdk-go/reputation" reputationapi "github.com/nspcc-dev/neofs-sdk-go/reputation"
) )
@ -43,7 +43,7 @@ type RemoteProvider struct {
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
} }
func (rp RemoteProvider) WithClient(c apiClient.Client) reputationcommon.WriterProvider { func (rp RemoteProvider) WithClient(c coreclient.Client) reputationcommon.WriterProvider {
return &TrustWriterProvider{ return &TrustWriterProvider{
client: c, client: c,
key: rp.key, key: rp.key,
@ -51,7 +51,7 @@ func (rp RemoteProvider) WithClient(c apiClient.Client) reputationcommon.WriterP
} }
type TrustWriterProvider struct { type TrustWriterProvider struct {
client apiClient.Client client coreclient.Client
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
} }
@ -71,7 +71,7 @@ func (twp *TrustWriterProvider) InitWriter(ctx reputationcommon.Context) (reputa
type RemoteTrustWriter struct { type RemoteTrustWriter struct {
eiCtx eigentrustcalc.Context eiCtx eigentrustcalc.Context
client apiClient.Client client coreclient.Client
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
} }

View file

@ -4,13 +4,14 @@ import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/client"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
"github.com/nspcc-dev/neofs-sdk-go/reputation" "github.com/nspcc-dev/neofs-sdk-go/reputation"
) )
type commonPrm struct { type commonPrm struct {
cli client.Client cli coreclient.Client
ctx context.Context ctx context.Context
@ -22,7 +23,7 @@ type commonPrm struct {
// SetClient sets base client for NeoFS API communication. // SetClient sets base client for NeoFS API communication.
// //
// Required parameter. // Required parameter.
func (x *commonPrm) SetClient(cli client.Client) { func (x *commonPrm) SetClient(cli coreclient.Client) {
x.cli = cli x.cli = cli
} }

View file

@ -5,9 +5,9 @@ import (
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/common" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/common"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/internal/client" internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-node/reputation/internal/client"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
apiClient "github.com/nspcc-dev/neofs-sdk-go/client"
reputationapi "github.com/nspcc-dev/neofs-sdk-go/reputation" reputationapi "github.com/nspcc-dev/neofs-sdk-go/reputation"
) )
@ -42,7 +42,7 @@ type RemoteProvider struct {
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
} }
func (rp RemoteProvider) WithClient(c apiClient.Client) reputationcommon.WriterProvider { func (rp RemoteProvider) WithClient(c coreclient.Client) reputationcommon.WriterProvider {
return &TrustWriterProvider{ return &TrustWriterProvider{
client: c, client: c,
key: rp.key, key: rp.key,
@ -50,7 +50,7 @@ func (rp RemoteProvider) WithClient(c apiClient.Client) reputationcommon.WriterP
} }
type TrustWriterProvider struct { type TrustWriterProvider struct {
client apiClient.Client client coreclient.Client
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
} }
@ -64,7 +64,7 @@ func (twp *TrustWriterProvider) InitWriter(ctx reputationcommon.Context) (reputa
type RemoteTrustWriter struct { type RemoteTrustWriter struct {
ctx reputationcommon.Context ctx reputationcommon.Context
client apiClient.Client client coreclient.Client
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
buf []*reputationapi.Trust buf []*reputationapi.Trust

2
go.mod
View file

@ -13,7 +13,7 @@ require (
github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/hrw v1.0.9
github.com/nspcc-dev/neo-go v0.98.0 github.com/nspcc-dev/neo-go v0.98.0
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 github.com/nspcc-dev/neofs-api-go/v2 v2.11.1
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211230072947-1fe37df88f80 github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659
github.com/nspcc-dev/tzhash v1.4.0 github.com/nspcc-dev/tzhash v1.4.0
github.com/panjf2000/ants/v2 v2.4.0 github.com/panjf2000/ants/v2 v2.4.0
github.com/paulmach/orb v0.2.2 github.com/paulmach/orb v0.2.2

BIN
go.sum

Binary file not shown.

View file

@ -1,15 +1,58 @@
package client package client
import ( import (
"context"
"io"
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client" rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/nspcc-dev/neofs-sdk-go/container"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/owner"
) )
// Client is an interface of NeoFS storage // Client is an interface of NeoFS storage
// node's client. // node's client.
type Client interface { type Client interface {
client.Client GetBalance(context.Context, *owner.ID, ...client.CallOption) (*client.BalanceOfRes, error)
PutContainer(context.Context, *container.Container, ...client.CallOption) (*client.ContainerPutRes, error)
GetContainer(context.Context, *cid.ID, ...client.CallOption) (*client.ContainerGetRes, error)
ListContainers(context.Context, *owner.ID, ...client.CallOption) (*client.ContainerListRes, error)
DeleteContainer(context.Context, *cid.ID, ...client.CallOption) (*client.ContainerDeleteRes, error)
EACL(context.Context, *cid.ID, ...client.CallOption) (*client.EACLRes, error)
SetEACL(context.Context, *eacl.Table, ...client.CallOption) (*client.SetEACLRes, error)
AnnounceContainerUsedSpace(context.Context, []container.UsedSpaceAnnouncement, ...client.CallOption) (*client.AnnounceSpaceRes, error)
EndpointInfo(context.Context, ...client.CallOption) (*client.EndpointInfoRes, error)
NetworkInfo(context.Context, ...client.CallOption) (*client.NetworkInfoRes, error)
PutObject(context.Context, *client.PutObjectParams, ...client.CallOption) (*client.ObjectPutRes, error)
DeleteObject(context.Context, *client.DeleteObjectParams, ...client.CallOption) (*client.ObjectDeleteRes, error)
GetObject(context.Context, *client.GetObjectParams, ...client.CallOption) (*client.ObjectGetRes, error)
HeadObject(context.Context, *client.ObjectHeaderParams, ...client.CallOption) (*client.ObjectHeadRes, error)
SearchObjects(context.Context, *client.SearchObjectParams, ...client.CallOption) (*client.ObjectSearchRes, error)
ObjectPayloadRangeData(context.Context, *client.RangeDataParams, ...client.CallOption) (*client.ObjectRangeRes, error)
HashObjectPayloadRanges(context.Context, *client.RangeChecksumParams, ...client.CallOption) (*client.ObjectRangeHashRes, error)
AnnounceLocalTrust(context.Context, client.AnnounceLocalTrustPrm, ...client.CallOption) (*client.AnnounceLocalTrustRes, error)
AnnounceIntermediateTrust(context.Context, client.AnnounceIntermediateTrustPrm, ...client.CallOption) (*client.AnnounceIntermediateTrustRes, error)
CreateSession(context.Context, uint64, ...client.CallOption) (*client.CreateSessionRes, error)
Raw() *rawclient.Client
Conn() io.Closer
}
// MultiAddressClient is an interface of the
// Client that supports multihost work.
type MultiAddressClient interface {
Client
// RawForAddress must return rawclient.Client // RawForAddress must return rawclient.Client
// for the passed network.Address. // for the passed network.Address.

View file

@ -5,6 +5,7 @@ import (
"crypto/ecdsa" "crypto/ecdsa"
"fmt" "fmt"
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup"
"github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/client"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
@ -16,11 +17,11 @@ import (
type Client struct { type Client struct {
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
c client.Client c clientcore.Client
} }
// WrapBasicClient wraps client.Client instance to use it for NeoFS API RPC. // WrapBasicClient wraps client.Client instance to use it for NeoFS API RPC.
func (x *Client) WrapBasicClient(c client.Client) { func (x *Client) WrapBasicClient(c clientcore.Client) {
x.c = c x.c = c
} }

View file

@ -24,7 +24,7 @@ type (
ClientCache struct { ClientCache struct {
log *zap.Logger log *zap.Logger
cache interface { cache interface {
Get(clientcore.NodeInfo) (client.Client, error) Get(clientcore.NodeInfo) (clientcore.Client, error)
CloseAll() CloseAll()
} }
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
@ -51,7 +51,7 @@ func newClientCache(p *clientCacheParams) *ClientCache {
} }
} }
func (c *ClientCache) Get(info clientcore.NodeInfo) (client.Client, error) { func (c *ClientCache) Get(info clientcore.NodeInfo) (clientcore.Client, error) {
// Because cache is used by `ClientCache` exclusively, // Because cache is used by `ClientCache` exclusively,
// client will always have valid key. // client will always have valid key.
return c.cache.Get(info) return c.cache.Get(info)

View file

@ -14,7 +14,7 @@ type (
// already created clients. // already created clients.
ClientCache struct { ClientCache struct {
mu *sync.RWMutex mu *sync.RWMutex
clients map[string]client.Client clients map[string]clientcore.Client
opts []client.Option opts []client.Option
} }
) )
@ -24,13 +24,13 @@ type (
func NewSDKClientCache(opts ...client.Option) *ClientCache { func NewSDKClientCache(opts ...client.Option) *ClientCache {
return &ClientCache{ return &ClientCache{
mu: new(sync.RWMutex), mu: new(sync.RWMutex),
clients: make(map[string]client.Client), clients: make(map[string]clientcore.Client),
opts: opts, opts: opts,
} }
} }
// Get function returns existing client or creates a new one. // Get function returns existing client or creates a new one.
func (c *ClientCache) Get(info clientcore.NodeInfo) (client.Client, error) { func (c *ClientCache) Get(info clientcore.NodeInfo) (clientcore.Client, error) {
netAddr := info.AddressGroup() netAddr := info.AddressGroup()
// multiaddr is used as a key in client cache since // multiaddr is used as a key in client cache since

View file

@ -8,6 +8,7 @@ import (
"sync" "sync"
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client" rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/nspcc-dev/neofs-sdk-go/container" "github.com/nspcc-dev/neofs-sdk-go/container"
@ -19,7 +20,7 @@ import (
type multiClient struct { type multiClient struct {
mtx sync.RWMutex mtx sync.RWMutex
clients map[string]client.Client clients map[string]clientcore.Client
addr network.AddressGroup addr network.AddressGroup
@ -28,14 +29,14 @@ type multiClient struct {
func newMultiClient(addr network.AddressGroup, opts []client.Option) *multiClient { func newMultiClient(addr network.AddressGroup, opts []client.Option) *multiClient {
return &multiClient{ return &multiClient{
clients: make(map[string]client.Client), clients: make(map[string]clientcore.Client),
addr: addr, addr: addr,
opts: opts, opts: opts,
} }
} }
// note: must be wrapped into mutex lock. // note: must be wrapped into mutex lock.
func (x *multiClient) createForAddress(addr network.Address) client.Client { func (x *multiClient) createForAddress(addr network.Address) clientcore.Client {
opts := append(x.opts, client.WithAddress(addr.HostAddr())) opts := append(x.opts, client.WithAddress(addr.HostAddr()))
if addr.TLSEnabled() { if addr.TLSEnabled() {
@ -53,7 +54,7 @@ func (x *multiClient) createForAddress(addr network.Address) client.Client {
return c return c
} }
func (x *multiClient) iterateClients(ctx context.Context, f func(client.Client) error) error { func (x *multiClient) iterateClients(ctx context.Context, f func(clientcore.Client) error) error {
var firstErr error var firstErr error
x.addr.IterateAddresses(func(addr network.Address) bool { x.addr.IterateAddresses(func(addr network.Address) bool {
@ -83,7 +84,7 @@ func (x *multiClient) iterateClients(ctx context.Context, f func(client.Client)
} }
func (x *multiClient) PutObject(ctx context.Context, p *client.PutObjectParams, opts ...client.CallOption) (res *client.ObjectPutRes, err error) { func (x *multiClient) PutObject(ctx context.Context, p *client.PutObjectParams, opts ...client.CallOption) (res *client.ObjectPutRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.PutObject(ctx, p, opts...) res, err = c.PutObject(ctx, p, opts...)
return err return err
}) })
@ -92,7 +93,7 @@ func (x *multiClient) PutObject(ctx context.Context, p *client.PutObjectParams,
} }
func (x *multiClient) GetBalance(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.BalanceOfRes, err error) { func (x *multiClient) GetBalance(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.BalanceOfRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.GetBalance(ctx, id, opts...) res, err = c.GetBalance(ctx, id, opts...)
return err return err
}) })
@ -101,7 +102,7 @@ func (x *multiClient) GetBalance(ctx context.Context, id *owner.ID, opts ...clie
} }
func (x *multiClient) PutContainer(ctx context.Context, cnr *container.Container, opts ...client.CallOption) (res *client.ContainerPutRes, err error) { func (x *multiClient) PutContainer(ctx context.Context, cnr *container.Container, opts ...client.CallOption) (res *client.ContainerPutRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.PutContainer(ctx, cnr, opts...) res, err = c.PutContainer(ctx, cnr, opts...)
return err return err
}) })
@ -110,7 +111,7 @@ func (x *multiClient) PutContainer(ctx context.Context, cnr *container.Container
} }
func (x *multiClient) GetContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerGetRes, err error) { func (x *multiClient) GetContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerGetRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.GetContainer(ctx, id, opts...) res, err = c.GetContainer(ctx, id, opts...)
return err return err
}) })
@ -119,7 +120,7 @@ func (x *multiClient) GetContainer(ctx context.Context, id *cid.ID, opts ...clie
} }
func (x *multiClient) ListContainers(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.ContainerListRes, err error) { func (x *multiClient) ListContainers(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.ContainerListRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.ListContainers(ctx, id, opts...) res, err = c.ListContainers(ctx, id, opts...)
return err return err
}) })
@ -128,7 +129,7 @@ func (x *multiClient) ListContainers(ctx context.Context, id *owner.ID, opts ...
} }
func (x *multiClient) DeleteContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerDeleteRes, err error) { func (x *multiClient) DeleteContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerDeleteRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.DeleteContainer(ctx, id, opts...) res, err = c.DeleteContainer(ctx, id, opts...)
return err return err
}) })
@ -137,7 +138,7 @@ func (x *multiClient) DeleteContainer(ctx context.Context, id *cid.ID, opts ...c
} }
func (x *multiClient) EACL(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.EACLRes, err error) { func (x *multiClient) EACL(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.EACLRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.EACL(ctx, id, opts...) res, err = c.EACL(ctx, id, opts...)
return err return err
}) })
@ -146,7 +147,7 @@ func (x *multiClient) EACL(ctx context.Context, id *cid.ID, opts ...client.CallO
} }
func (x *multiClient) SetEACL(ctx context.Context, t *eacl.Table, opts ...client.CallOption) (res *client.SetEACLRes, err error) { func (x *multiClient) SetEACL(ctx context.Context, t *eacl.Table, opts ...client.CallOption) (res *client.SetEACLRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.SetEACL(ctx, t, opts...) res, err = c.SetEACL(ctx, t, opts...)
return err return err
}) })
@ -155,7 +156,7 @@ func (x *multiClient) SetEACL(ctx context.Context, t *eacl.Table, opts ...client
} }
func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, as []container.UsedSpaceAnnouncement, opts ...client.CallOption) (res *client.AnnounceSpaceRes, err error) { func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, as []container.UsedSpaceAnnouncement, opts ...client.CallOption) (res *client.AnnounceSpaceRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.AnnounceContainerUsedSpace(ctx, as, opts...) res, err = c.AnnounceContainerUsedSpace(ctx, as, opts...)
return err return err
}) })
@ -164,7 +165,7 @@ func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, as []conta
} }
func (x *multiClient) EndpointInfo(ctx context.Context, opts ...client.CallOption) (res *client.EndpointInfoRes, err error) { func (x *multiClient) EndpointInfo(ctx context.Context, opts ...client.CallOption) (res *client.EndpointInfoRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.EndpointInfo(ctx, opts...) res, err = c.EndpointInfo(ctx, opts...)
return err return err
}) })
@ -173,7 +174,7 @@ func (x *multiClient) EndpointInfo(ctx context.Context, opts ...client.CallOptio
} }
func (x *multiClient) NetworkInfo(ctx context.Context, opts ...client.CallOption) (res *client.NetworkInfoRes, err error) { func (x *multiClient) NetworkInfo(ctx context.Context, opts ...client.CallOption) (res *client.NetworkInfoRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.NetworkInfo(ctx, opts...) res, err = c.NetworkInfo(ctx, opts...)
return err return err
}) })
@ -182,7 +183,7 @@ func (x *multiClient) NetworkInfo(ctx context.Context, opts ...client.CallOption
} }
func (x *multiClient) DeleteObject(ctx context.Context, p *client.DeleteObjectParams, opts ...client.CallOption) (res *client.ObjectDeleteRes, err error) { func (x *multiClient) DeleteObject(ctx context.Context, p *client.DeleteObjectParams, opts ...client.CallOption) (res *client.ObjectDeleteRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.DeleteObject(ctx, p, opts...) res, err = c.DeleteObject(ctx, p, opts...)
return err return err
}) })
@ -191,7 +192,7 @@ func (x *multiClient) DeleteObject(ctx context.Context, p *client.DeleteObjectPa
} }
func (x *multiClient) GetObject(ctx context.Context, p *client.GetObjectParams, opts ...client.CallOption) (res *client.ObjectGetRes, err error) { func (x *multiClient) GetObject(ctx context.Context, p *client.GetObjectParams, opts ...client.CallOption) (res *client.ObjectGetRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.GetObject(ctx, p, opts...) res, err = c.GetObject(ctx, p, opts...)
return err return err
}) })
@ -200,7 +201,7 @@ func (x *multiClient) GetObject(ctx context.Context, p *client.GetObjectParams,
} }
func (x *multiClient) ObjectPayloadRangeData(ctx context.Context, p *client.RangeDataParams, opts ...client.CallOption) (res *client.ObjectRangeRes, err error) { func (x *multiClient) ObjectPayloadRangeData(ctx context.Context, p *client.RangeDataParams, opts ...client.CallOption) (res *client.ObjectRangeRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.ObjectPayloadRangeData(ctx, p, opts...) res, err = c.ObjectPayloadRangeData(ctx, p, opts...)
return err return err
}) })
@ -209,7 +210,7 @@ func (x *multiClient) ObjectPayloadRangeData(ctx context.Context, p *client.Rang
} }
func (x *multiClient) HeadObject(ctx context.Context, p *client.ObjectHeaderParams, opts ...client.CallOption) (res *client.ObjectHeadRes, err error) { func (x *multiClient) HeadObject(ctx context.Context, p *client.ObjectHeaderParams, opts ...client.CallOption) (res *client.ObjectHeadRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.HeadObject(ctx, p, opts...) res, err = c.HeadObject(ctx, p, opts...)
return err return err
}) })
@ -218,7 +219,7 @@ func (x *multiClient) HeadObject(ctx context.Context, p *client.ObjectHeaderPara
} }
func (x *multiClient) HashObjectPayloadRanges(ctx context.Context, p *client.RangeChecksumParams, opts ...client.CallOption) (res *client.ObjectRangeHashRes, err error) { func (x *multiClient) HashObjectPayloadRanges(ctx context.Context, p *client.RangeChecksumParams, opts ...client.CallOption) (res *client.ObjectRangeHashRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.HashObjectPayloadRanges(ctx, p, opts...) res, err = c.HashObjectPayloadRanges(ctx, p, opts...)
return err return err
}) })
@ -227,7 +228,7 @@ func (x *multiClient) HashObjectPayloadRanges(ctx context.Context, p *client.Ran
} }
func (x *multiClient) SearchObjects(ctx context.Context, p *client.SearchObjectParams, opts ...client.CallOption) (res *client.ObjectSearchRes, err error) { func (x *multiClient) SearchObjects(ctx context.Context, p *client.SearchObjectParams, opts ...client.CallOption) (res *client.ObjectSearchRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.SearchObjects(ctx, p, opts...) res, err = c.SearchObjects(ctx, p, opts...)
return err return err
}) })
@ -236,7 +237,7 @@ func (x *multiClient) SearchObjects(ctx context.Context, p *client.SearchObjectP
} }
func (x *multiClient) CreateSession(ctx context.Context, exp uint64, opts ...client.CallOption) (res *client.CreateSessionRes, err error) { func (x *multiClient) CreateSession(ctx context.Context, exp uint64, opts ...client.CallOption) (res *client.CreateSessionRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.CreateSession(ctx, exp, opts...) res, err = c.CreateSession(ctx, exp, opts...)
return err return err
}) })
@ -245,7 +246,7 @@ func (x *multiClient) CreateSession(ctx context.Context, exp uint64, opts ...cli
} }
func (x *multiClient) AnnounceLocalTrust(ctx context.Context, p client.AnnounceLocalTrustPrm, opts ...client.CallOption) (res *client.AnnounceLocalTrustRes, err error) { func (x *multiClient) AnnounceLocalTrust(ctx context.Context, p client.AnnounceLocalTrustPrm, opts ...client.CallOption) (res *client.AnnounceLocalTrustRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.AnnounceLocalTrust(ctx, p, opts...) res, err = c.AnnounceLocalTrust(ctx, p, opts...)
return err return err
}) })
@ -254,7 +255,7 @@ func (x *multiClient) AnnounceLocalTrust(ctx context.Context, p client.AnnounceL
} }
func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, p client.AnnounceIntermediateTrustPrm, opts ...client.CallOption) (res *client.AnnounceIntermediateTrustRes, err error) { func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, p client.AnnounceIntermediateTrustPrm, opts ...client.CallOption) (res *client.AnnounceIntermediateTrustRes, err error) {
err = x.iterateClients(ctx, func(c client.Client) error { err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.AnnounceIntermediateTrust(ctx, p, opts...) res, err = c.AnnounceIntermediateTrust(ctx, p, opts...)
return err return err
}) })
@ -288,7 +289,7 @@ func (x *multiClient) RawForAddress(addr network.Address) *rawclient.Client {
return x.client(addr).Raw() return x.client(addr).Raw()
} }
func (x *multiClient) client(addr network.Address) client.Client { func (x *multiClient) client(addr network.Address) clientcore.Client {
x.mtx.Lock() x.mtx.Lock()
strAddr := addr.String() strAddr := addr.String()

View file

@ -32,7 +32,7 @@ type RangeHashPrm struct {
salt []byte salt []byte
} }
type RequestForwarder func(coreclient.NodeInfo, coreclient.Client) (*objectSDK.Object, error) type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) (*objectSDK.Object, error)
// HeadPrm groups parameters of Head service call. // HeadPrm groups parameters of Head service call.
type HeadPrm struct { type HeadPrm struct {

View file

@ -99,7 +99,7 @@ func WithLocalStorageEngine(e *engine.StorageEngine) Option {
} }
type ClientConstructor interface { type ClientConstructor interface {
Get(client.NodeInfo) (client.Client, error) Get(client.NodeInfo) (client.MultiAddressClient, error)
} }
// WithClientConstructor returns option to set constructor of remote node clients. // WithClientConstructor returns option to set constructor of remote node clients.

View file

@ -23,7 +23,7 @@ type clientCacheWrapper struct {
} }
type clientWrapper struct { type clientWrapper struct {
client coreclient.Client client coreclient.MultiAddressClient
} }
type storageEngineWrapper struct { type storageEngineWrapper struct {

View file

@ -48,7 +48,7 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
if !commonPrm.LocalOnly() { if !commonPrm.LocalOnly() {
var onceResign sync.Once var onceResign sync.Once
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.Client, pubkey []byte) (*objectSDK.Object, error) { p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
var err error var err error
key, err := s.keyStorage.GetKey(nil) key, err := s.keyStorage.GetKey(nil)
@ -178,7 +178,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
return nil, err return nil, err
} }
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.Client, pubkey []byte) (*objectSDK.Object, error) { p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
var err error var err error
// once compose and resign forwarding request // once compose and resign forwarding request
@ -333,7 +333,7 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp
if !commonPrm.LocalOnly() { if !commonPrm.LocalOnly() {
var onceResign sync.Once var onceResign sync.Once
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.Client, pubkey []byte) (*objectSDK.Object, error) { p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
var err error var err error
key, err := s.keyStorage.GetKey(nil) key, err := s.keyStorage.GetKey(nil)
@ -511,8 +511,8 @@ func toShortObjectHeader(hdr *object.Object) objectV2.GetHeaderPart {
return sh return sh
} }
func groupAddressRequestForwarder(f func(network.Address, client.Client, []byte) (*objectSDK.Object, error)) getsvc.RequestForwarder { func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) (*objectSDK.Object, error)) getsvc.RequestForwarder {
return func(info client.NodeInfo, c client.Client) (*objectSDK.Object, error) { return func(info client.NodeInfo, c client.MultiAddressClient) (*objectSDK.Object, error) {
var ( var (
firstErr error firstErr error
res *objectSDK.Object res *objectSDK.Object

View file

@ -9,13 +9,12 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client" internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/netmap"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
) )
type ClientConstructor interface { type ClientConstructor interface {
Get(clientcore.NodeInfo) (client.Client, error) Get(clientcore.NodeInfo) (clientcore.Client, error)
} }
// RemoteHeader represents utility for getting // RemoteHeader represents utility for getting

View file

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
session2 "github.com/nspcc-dev/neofs-api-go/v2/session" session2 "github.com/nspcc-dev/neofs-api-go/v2/session"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/client"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -15,7 +16,7 @@ import (
) )
type commonPrm struct { type commonPrm struct {
cli client.Client cli coreclient.Client
ctx context.Context ctx context.Context
@ -25,7 +26,7 @@ type commonPrm struct {
// SetClient sets base client for NeoFS API communication. // SetClient sets base client for NeoFS API communication.
// //
// Required parameter. // Required parameter.
func (x *commonPrm) SetClient(cli client.Client) { func (x *commonPrm) SetClient(cli coreclient.Client) {
x.cli = cli x.cli = cli
} }

View file

@ -14,7 +14,7 @@ type PutInitPrm struct {
traverseOpts []placement.Option traverseOpts []placement.Option
relay func(client.NodeInfo, client.Client) error relay func(client.NodeInfo, client.MultiAddressClient) error
} }
type PutChunkPrm struct { type PutChunkPrm struct {
@ -45,7 +45,7 @@ func (p *PutInitPrm) WithObject(v *object.RawObject) *PutInitPrm {
return p return p
} }
func (p *PutInitPrm) WithRelay(f func(client.NodeInfo, client.Client) error) *PutInitPrm { func (p *PutInitPrm) WithRelay(f func(client.NodeInfo, client.MultiAddressClient) error) *PutInitPrm {
if p != nil { if p != nil {
p.relay = f p.relay = f
} }

View file

@ -29,7 +29,7 @@ type Service struct {
type Option func(*cfg) type Option func(*cfg)
type ClientConstructor interface { type ClientConstructor interface {
Get(client.NodeInfo) (client.Client, error) Get(client.NodeInfo) (client.MultiAddressClient, error)
} }
type cfg struct { type cfg struct {

View file

@ -19,7 +19,7 @@ type Streamer struct {
target transformer.ObjectTarget target transformer.ObjectTarget
relay func(client.NodeInfo, client.Client) error relay func(client.NodeInfo, client.MultiAddressClient) error
maxPayloadSz uint64 // network config maxPayloadSz uint64 // network config
} }

View file

@ -127,7 +127,7 @@ func (s *streamer) CloseAndRecv() (*object.PutResponse, error) {
return fromPutResponse(resp), nil return fromPutResponse(resp), nil
} }
func (s *streamer) relayRequest(info client.NodeInfo, c client.Client) error { func (s *streamer) relayRequest(info client.NodeInfo, c client.MultiAddressClient) error {
// open stream // open stream
resp := new(object.PutResponse) resp := new(object.PutResponse)

View file

@ -28,7 +28,7 @@ type IDListWriter interface {
// RequestForwarder is a callback for forwarding of the // RequestForwarder is a callback for forwarding of the
// original Search requests. // original Search requests.
type RequestForwarder func(coreclient.NodeInfo, coreclient.Client) ([]*objectSDK.ID, error) type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]*objectSDK.ID, error)
// SetCommonParameters sets common parameters of the operation. // SetCommonParameters sets common parameters of the operation.
func (p *Prm) SetCommonParameters(common *util.CommonPrm) { func (p *Prm) SetCommonParameters(common *util.CommonPrm) {

View file

@ -29,7 +29,7 @@ type searchClient interface {
} }
type ClientConstructor interface { type ClientConstructor interface {
Get(client.NodeInfo) (client.Client, error) Get(client.NodeInfo) (client.MultiAddressClient, error)
} }
type cfg struct { type cfg struct {

View file

@ -26,7 +26,7 @@ type clientConstructorWrapper struct {
} }
type clientWrapper struct { type clientWrapper struct {
client client.Client client client.MultiAddressClient
} }
type storageEngineWrapper engine.StorageEngine type storageEngineWrapper engine.StorageEngine

View file

@ -44,7 +44,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
return nil, err return nil, err
} }
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.Client, pubkey []byte) ([]*objectSDK.ID, error) { p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]*objectSDK.ID, error) {
var err error var err error
// once compose and resign forwarding request // once compose and resign forwarding request
@ -114,8 +114,8 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
return p, nil return p, nil
} }
func groupAddressRequestForwarder(f func(network.Address, client.Client, []byte) ([]*objectSDK.ID, error)) searchsvc.RequestForwarder { func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]*objectSDK.ID, error)) searchsvc.RequestForwarder {
return func(info client.NodeInfo, c client.Client) ([]*objectSDK.ID, error) { return func(info client.NodeInfo, c client.MultiAddressClient) ([]*objectSDK.ID, error) {
var ( var (
firstErr error firstErr error
res []*objectSDK.ID res []*objectSDK.ID